case的一种用法

月的总数量,按月查询显示如下的SQL语句
1月   2月    3月 。。。。。
100   2000   4554 。。。。

SQL:

select sum(case month when 1 then num else o end)as 1yue,sum(case month when 2 then num else o end)as 2yue.......group by month

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章