27,579
社区成员
发帖
与我相关
我的任务
分享
select 年月,部门,姓名,编号,
sum(case when 年月='201401' then sfgz else 0 end ) as '一月',
sum(case when 年月='201402' then sfgz else 0 end ) as '二月',
sum(case when 年月='201403' then sfgz else 0 end ) as '三月',
sum(case when 年月='201404' then sfgz else 0 end ) as '四月',
sum(case when 年月='201405' then sfgz else 0 end ) as '五月',
sum(case when 年月='201406' then sfgz else 0 end ) as '六月',
sum(case when 年月='201407' then sfgz else 0 end ) as '七月',
sum(case when 年月='201408' then sfgz else 0 end ) as '八月',
sum(case when 年月='201409' then sfgz else 0 end ) as '九月',
sum(case when 年月='201410' then sfgz else 0 end ) as '十月',
sum(case when 年月='201411' then sfgz else 0 end ) as '十一月',
sum(case when 年月='201412' then sfgz else 0 end ) as '十二月'
from
b,c
where
b.编号=c.编号
and
c.id=b.id
and
left(年月,4)='2014'
and
b.编号='18'
and
PayId<>'21'
group by
年月,部门,姓名,编号