首页 新闻 会员 周边

sqlserver查询语句

0
[待解决问题]

select * from (
select year,case when t.month=1 then (select amount from mm s where s.year=t.year and s.month=1) end as m1,
case when t.month=2 then (select amount from mm s where s.year=t.year and s.month=2) end as m2,
case when t.month=3 then (select amount from mm s where s.year=t.year and s.month=3) end as m3,
case when t.month=4 then (select amount from mm s where s.year=t.year and s.month=4) end as m4
from mm t) g

请问想要得到这种格式 需要怎么修改一下

--year m1 m2 m3 m4
--1991 1.1 1.2 1.3 1.4
--1992 2.1 2.2 2.3 2.4

又是没有bug的一天的主页 又是没有bug的一天 | 初学一级 | 园豆:149
提问于:2017-03-22 15:03
< >
分享
所有回答(3)
0

行转列???

liuxb1991 | 园豆:661 (小虾三级) | 2017-03-23 08:38
0

兄弟,你起码把mm表的数据展示出来吧,部分也行

悦光阴 | 园豆:2251 (老鸟四级) | 2017-03-24 12:59
0

最简单的方法是放到字典中 在界面上处理

小眼睛老鼠 | 园豆:2731 (老鸟四级) | 2017-03-30 13:11
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册