Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
advaghela
Starting Member
1 Post |
Posted - 2014-09-02 : 01:34:18
|
select sum(case flag when 1 then 1 else 0) as active,sum(case flag when 2 then 1 else 0) as closedfrom tableoutput------------active|close ------------ 29| 30------------i need this output like this ..-----------------total_active | 29-----------------total_closed | 30-----------------please help me...thanks in advance.. |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2014-09-02 : 03:17:18
|
[code]select 'total active' , count(*) from table where flag = 1union allselect 'total closed' , count(*) from table where flag = 2[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2014-09-02 : 07:44:34
|
orselect case flag when 1 then 'total active' when 2 then 'total closed' end as flag, count(*) as total from tablegroup by case flag when 1 then 'total active' when 2 then 'total closed' endMadhivananFailing to plan is Planning to fail |
|
|
|
|
|