排名
7
文章
192
粉丝
15
评论
16
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:
50010702506256


欢迎加群交流技术

数据表
create table temp (
year int,
month int,
amout float
)
insert temp values(1991,1,1.1)
insert temp values(1991,2,1.2)
insert temp values(1991,3,1.3)
insert temp values(1991,4,1.4)
insert temp values(1992,1,2.1)
insert temp values(1992,2,2.2)
insert temp values(1992,3,2.3)
insert temp values(1992,4,2.4)
实现根据查询达到以下效果
- select YEAR
- ,SUM(case when MONTH = 1 then amout else 0 end) as m1
- ,SUM(case when MONTH = 2 then amout else 0 end) as m2
- ,SUM(case when MONTH = 3 then amout else 0 end) as m3
- ,SUM(case when MONTH = 4 then amout else 0 end) as m4
- from temp
- group by year
评价