62,268
社区成员
发帖
与我相关
我的任务
分享
select no,sum(case m when 1 then total else 0 end) as '一月',sum(case m when 2 then total else 0 end) as '二月'
from
(select month(cdate) as m,no,sum(num) as total from test group by no,month(cdate) ) DERIVEDTBL
group by no
select 编号,
1月(2009-01)=isnull(sum(case course when '2009-01' then result end),0),
2月(2009-02)=isnull(sum(case course when '2009-02' then result end),0)
from 表
group by 编号
order by 编号