热线电话:13121318867

登录
2020-09-07 阅读量: 1143
sql面试题:一维表如何转换成二维表

问题:image.png

解答:

select cus_id,sum(case acc_type when 'checking' then acc_no else null end) as 'checking account',

sum(case acc_type when 'saving' then acc_no else null end) as 'saving account'

from t_a

group by cus_id;

用到case..when ..then..else语句

31.8367
0
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子