count - Multiple where clauses in one row sql -


i want take below statement , fuse 1 query.

select count(*) count1 month='11' , flag = 1 select count(*) count2 month='11' , flag = 2 select count(*) count1 month='12' , flag = 1     select count(*) count2 month='12' , flag = 2 

i want display 1 query columns count1 , count2 , rows month 11 , month 12.

is there syntax this?

you can combine sum , case various counts in 1 go:

select     month,     sum(case when flag=1 1 else 0 end) count1,     sum(case when flag=2 1 else 0 end) count2     ... month in ('11','12') group     month /* other columns? */ 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -