56,679
社区成员
发帖
与我相关
我的任务
分享
select B.dep,B.dname
,sum(case when A.mon ='一月' then yj end) as 一月份
,sum(case when A.mon ='二月' then yj end) as 二月份
,sum(case when A.mon ='三月' then yj end) as 三月份
from tb1 A,tb2 B
where A.dep = B.dep
group by B.dep,B.dname
select a.dep,a.dname,
sum(if(mon='一月份',yj,0)) as `一月份`,
sum(if(mon='二月份',yj,0)) as `二月份`,
sum(if(mon='三月份',yj,0)) as `三月份`
from 图二 a left join 图一 b on a.dep=b.dep
group by a.dep,a.dname