출처 : http://www.sqler.com/bSQLQA/398435
쿼리를 작성하다보면 특정한 조건의 카운트를 한 번에 하고 싶을 때가 있다.
이때는 아래와 같이 사용한다.
select
COUNT(case when col1 = 'P' and col2 = 'Y' then 1 end),
COUNT(case when col1 = 'P' and col2 = 'N' then 1 end),
COUNT(case when col1 = 'B' and col2 = 'Y' then 1 end),
COUNT(case when col1 = 'B' and col2 = 'N' then 1 end)
from table_name
where col3 = '2014'