我的表测试有值
Status | DATE
X | 25-11-2012
X | 25-11-2012
Y | 25-11-2012
Z | 25-11-2012
X | 26-11-2012
Y | 26-11-2012
Y | 26-11-2012
Z | 26-11-2012
我希望显示
DATE | X | Y | Z |
25-11-2012 | 2 | 1 | 1 |
26-11-2012 | 1 | 2 | 1 |
请帮助我。
答案 0 :(得分:0)
select
date_col,
count(case when status='X' then 1 end) as X,
count(case when status='Y' then 1 end) as Y,
count(case when status='Z' then 1 end) as Z
from your_table
group by date_col;