michaela18
Technical User
I have the following:
Select (1+len(NULLIF(LTRIM(CodeList),''))-len(replace(NULLIF(LTRIM(CodeList),''),' ',''))) * count (*) as 'IBM_ACS'
from history
where order in ('In process', 'Order')
and date = '20100210'
and PromoCode IN ('107', 'VW109', '118')
group by codelist
This will count the number of words in a record then multiply that by the count. Some records in the Codelist field has blanks, but my select still counts them. How can I count everything without the group by as 1 sum, and without the blanks/nulls.
Select (1+len(NULLIF(LTRIM(CodeList),''))-len(replace(NULLIF(LTRIM(CodeList),''),' ',''))) * count (*) as 'IBM_ACS'
from history
where order in ('In process', 'Order')
and date = '20100210'
and PromoCode IN ('107', 'VW109', '118')
group by codelist
This will count the number of words in a record then multiply that by the count. Some records in the Codelist field has blanks, but my select still counts them. How can I count everything without the group by as 1 sum, and without the blanks/nulls.