表YEA如下图所示:
YEAR MONTH AMOUNT
1991 1 1.1
1991 2 1.2
1991 3 1.3
1991 4 1.4
1992 1 2.1
1992 2 2.2
1992 3 2.3
1992 4 2.4
请将表YEA转置,按如下方式显示
YEAR M1 M2 M3 M4
1991 1.1 1.2 1.3 1.4
1992 2.1 2.2 2.3 2.4
select * from yea pivot(sum(amount) for month in ('1' m1,'2' m2,'3' m3,'4'm4));
阅读(1248) | 评论(0) | 转发(0) |