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

Posted lanqiu5ge

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了一道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

以上是关于一道SQL面试题——表行列数据转换(表转置)的主要内容,如果未能解决你的问题,请参考以下文章