SQL行列转换算法1

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

select dname,b.yj '一月份',c.yj '二月份',d.yj '三月份' from table2 a left join table1 b on a.dep=b.dep and b.mon='一月份' left join table1 c on a.dep = c.dep and c.mon='二月份' left join table1 d on a.dep = d.dep and d.mon='三月份'