|
-
May 3rd, 2005, 01:00 AM
#1
count
sql2000:
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
is it possible to count number of times when result is '10'?.
-
May 3rd, 2005, 01:55 PM
#2
Re: count
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|