Hi
I'm a bit of a sql novice and am writing the following stored proc to select the following fields.
select i3_rowid, companyname, phonenumber, companytitle, companyforename, companysurname, datacode,
case when(surname1 <> '' and surname1 is not null) then 1 else 0 end as subs
from calllist
where i3_rowid in
(select i3_rowid from callhistory where finishcode = 'Quote Sent' and
calldate between '19 july 2005 00:00' and '19 july 2005 23:59')
There are 11 more surname fields, which I need to include in the 'subs' field, i.e. I need some code which says 'if surname1 <> '' 1 else 0 + if surname2 <> '' then 1 else 0 etc', to give me the total number of subscribers to this product in one field. Is this possible with case statements, or am i going about it the wrong way?
Thanks a lot in advance.
I'm a bit of a sql novice and am writing the following stored proc to select the following fields.
select i3_rowid, companyname, phonenumber, companytitle, companyforename, companysurname, datacode,
case when(surname1 <> '' and surname1 is not null) then 1 else 0 end as subs
from calllist
where i3_rowid in
(select i3_rowid from callhistory where finishcode = 'Quote Sent' and
calldate between '19 july 2005 00:00' and '19 july 2005 23:59')
There are 11 more surname fields, which I need to include in the 'subs' field, i.e. I need some code which says 'if surname1 <> '' 1 else 0 + if surname2 <> '' then 1 else 0 etc', to give me the total number of subscribers to this product in one field. Is this possible with case statements, or am i going about it the wrong way?
Thanks a lot in advance.