如何用SQL开通过上面的数据表生成下面的数据表格呢?
感觉怎么写都不太能搞定。
有数据库大神能指点一下不???
select id, name ,(case when years=1992 then cost else 0 end) as year1992 from pivot group by name;
简单的写了一下,可是这个确爆出了奇怪的错误》》
ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'nctest.pivot.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
这要如何求解了?
感谢各位的帮助。以及自己解决了。。
也可以用if代替case when