小弟初学sql,像高手求教,谢谢! |
|
15分 |
select year, max(case month when 1 then amount else 0 end) as m1, max(case month when 2 then amount else 0 end) as m2, max(case month when 3 then amount else 0 end) as m3, max(case month when 4 then amount else 0 end) as m4 from t1 group by year; |
5分 |
http://blog.csdn.net/acmain_chm/article/details/4283943
MySQL交叉表 在某些数据库中有交叉表,但在MySQL中却没有这个功能,但网上看到有不少朋友想找出一个解决方法,特发贴集思广义。http://topic.csdn.net/u/20090530/23/0b782674-4b0b-4cf5-bc1a-e8914aaee5ab.html?96198现整理解法如下:数据样本: create table tx( id int primary key, c1 c… |
谢谢两位高手!
|