我有以下数据集
TRAN_DT; CONENT; TYPE
01/01/2018 12:00:00; AAA ; 1
01/01/2018 12:00:00; AAA ; 2
01/01/2018 12:00:00; AAA ; 3
01/01/2018 01:00:00; FFF ; 1
01/01/2018 01:00:00; FFF ; 2
我需要我的结果像
01/01/2018 12:00:00;01/01/2018 01:00:00
1 AAA ;FFF
2 AAA ;FFF
3 AAA
谢谢。
答案 0 :(得分:1)
我认为您需要条件聚合:
select type,
max(case when tran_dt = '01/01/2018 12:00:00' then conent end) as c_20180101_12,
max(case when tran_dt = '01/01/2018 01:00:00' then conent end) as c_20180101_01
from t
group by type
order by type;