码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2018-08-18 10:31:23      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:图片   http   code   one   end   分享   when   art   面试题   

技术分享图片
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面试题——表行列数据转换(表转置)

标签:图片   http   code   one   end   分享   when   art   面试题   

原文地址:https://www.cnblogs.com/lanqiu5ge/p/9496000.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!