一道SQL面试题——表行列数据转换(表转置)


SQL语句如下:

select
country, 
sum(case when type='A' then money end) as A,
sum(case when type='B' then money end) as B,
sum(case when type='C' then money end) as C
from table1
group by country

本文转自:https://blog.csdn.net/Eastmount/article/details/50559008

posted @ 2018-08-18 00:31  lanqiu5ge  阅读(1016)  评论(0编辑  收藏  举报