0

値を持つテーブルテストがあります

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 |

同じことを手伝ってください。

4

1 に答える 1

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;
于 2012-11-27T13:15:03.100 に答える