共3年的数据
那么
select dm,
sum(isnull(case when convert(char(4),rq,120)='2002' then je end,0)) as '2002je',
sum(isnull(case when convert(char(4),rq,120)='2003' then je end,0)) as '2003je',
sum(isnull(case when convert(char(4),rq,120)='2004' then je end,0)) as '2004je',
lb
from 表
group by dm,lb
那么
select dm,
sum(isnull(case when convert(char(4),rq,120)='2002' then je end,0)) as '2002je',
sum(isnull(case when convert(char(4),rq,120)='2003' then je end,0)) as '2003je',
sum(isnull(case when convert(char(4),rq,120)='2004' then je end,0)) as '2004je',
lb
from 表
group by dm,lb
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货