sql server 2012 - TSQL Reversing query to display cols as rows -
the following query gives me
active inactive 3 1 select sum(case when active = 'true' 1 else 0 end) active, sum(case when active = 'false' 1 else 0 end) inactive events
i like:
status count active 3 inactive 1
how can inverse this?
there no need pivoting resultset, use simple group by
:
select case active when 'true' 'active' when 'false' 'inactive' end status ,count(*) count events active in ('true', 'false') group case active when 'true' 'active' when 'false' 'inactive' end;
Comments
Post a Comment