下面这个第一个变换用sql怎么实现呢
sql吧
全部回复
仅看楼主
level 1
CXuXuu℉ 楼主
2022年02月22日 01点02分 1
level 5
列转行,select id,max(case when 品类=a then 金额 else 0 end) as a,max(case when 品类=b then 金额 else 0 end) as b,max(case when 品类=c then 金额 else 0 end) as c from 表 group by id
2022年02月22日 11点02分 2
强啊[真棒] 不过max应该改成sum吧
2022年02月22日 12点02分
@CXuXuu℉ 是得改成sum
2022年02月24日 00点02分
level 8
方案1 PIVOT
方案2 子查询
2022年02月28日 03点02分 3
1