Foxtable(狐表)用户栏目专家坐堂 → 求一sql语句


  共有9136人关注过本帖树形打印复制链接

主题:求一sql语句

帅哥哟,离线,有人找我吗?
lin_hailun
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:狐神 帖子:6708 积分:34304 威望:0 精华:11 注册:2012/8/18 23:10:00
  发帖心情 Post By:2012/11/14 17:19:00 [显示全部帖子]

 在网上查了下,终于是找到了。

select good_id,
一月 = max(case when m = 1 then price else null end ),
二月 = max(case when m = 2 then price else null end ),
三月 = max(case when m = 3 then price else null end ),
四月 = max(case when m = 4 then price else null end ),
五月 = max(case when m = 5 then price else null end ),
六月 = max(case when m = 6 then price else null end ),
七月 = max(case when m = 7 then price else null end ),
八月 = max(case when m = 8 then price else null end ),
九月 = max(case when m = 9 then price else null end ),
十月 = max(case when m = 10 then price else null end ),
十一月 = max(case when m = 11 then price else null end ),
十二月 = max(case when m = 12 then price else null end )
from prices group by good_id
[此贴子已经被作者于2012-11-14 17:19:21编辑过]

 回到顶部