Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 07, 2012 03:27 AM by imobsuz
Dec 07, 2012 01:50 AM|LINK
how to write a query to get the count of total activities,count(act) where status='c'
,coun(act) where status='o' in single table from single table
i have a table name 'A' in which i have all the activities with status='c'
now i need aquery to get tha table 'B' like this
totcount cnt(act where status='c') cnt(act where status='o')
250 100 150
Dec 07, 2012 02:21 AM|LINK
A.Count_C + A.Count_O as 'Total', A.Count_C, A.Count_O
(select count(act) from tableName where status='c') as Count_C,
(select count(act) from tableName where status='o') as Count_O
hope this helps...
Dec 07, 2012 03:27 AM|LINK
count(*) as TotCount,
sum(case when act = 'c' then 1 else 0 end) as CountC,
sum(case when act = 'o' then 1 else 0 end) as CountO
Hope this helps.