我有3列:
Date Type Item
1/1/2015 A X
3/2/2015 B X
1/6/2015 A Y
3/7/2015 B Y
我想用表格显示表格:
DateA Type DateB Type Item
1/1/2015 A 3/2/2015 B X
1/6/2015 A 3/7/2015 B Y
我该怎么做?
答案 0 :(得分:0)
这看起来像条件聚合:
select max(case when type = 'A' then date end) as DateA, 'A' as TypeA,
max(case when type = 'B' then date end) as DateB, 'B' as TypeB
item
from t
group by item;