sql2000:
is it possible to count number of times when result is '10'?.Code:select table1.field1, table1.field2, case when table1.field5 = 10 then '10'
when table.field5 = 11 then '11' end as result, table1.field6
from table1
Printable View
sql2000:
is it possible to count number of times when result is '10'?.Code:select table1.field1, table1.field2, case when table1.field5 = 10 then '10'
when table.field5 = 11 then '11' end as result, table1.field6
from table1
Yes using a case wrapped by sum will make it work.
select table1.column1, table1.column2, (case table1.column5 when 10 then '10'
when 11 then '11' end) as result, table1.column6, sum(case when table1.column5 = 10 then 1 else 0 end) as count_ten
from table1
group by
table1.column1, table1.column2, (case table1.column5 when 10 then '10'
when 11 then '11' end), table1.column6