SQL行专列

一张表

SQL行专列
查询结果为
SQL行专列
1
2
3
4
5
--行转列
select  years,(select amount from Tb_Amount as A where month=1 and A.years=Tb_Amount.years)as m1,
(select amount from Tb_Amount as A where month=2 and A.years=Tb_Amount.years)as m2,
(select amount from Tb_Amount as A where month=3 and A.years=Tb_Amount.years)as m3
from  Tb_Amount group by  years

 

SQL行专列,布布扣,bubuko.com

SQL行专列

上一篇:【转】[Asp.net]常见数据导入Excel,Excel数据导入数据库解决方案,总有一款适合你!


下一篇:MySQL卸载(rpm)