sql 同时实现行转列和列转行

sql 同时实现行转列和列转行

 select Name,序号,类型,
[1月]=MAX(case when Month=1 then Value end),
[2月]=MAX(case when Month=2 then Value end),
[3月]=MAX(case when Month=3 then Value end)
from 
(
select Name,Month,'序号'=1,'类型'='吃饭',Meet as Value from aaa
union all
select Name,MONTH,'序号'=2,'类型'='唱歌',Singing as Value from aaa
union all
select Name,MONTH,'序号'=3,'类型'='游戏',Game as Value from aaa
) as BBB
group by BBB.Name,BBB.序号,BBB.类型

 

相关文章:

  • 2021-05-20
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
  • 2021-08-11
  • 2021-09-14
猜你喜欢
  • 2021-05-26
  • 2021-06-28
  • 2022-02-17
  • 2021-11-26
  • 2021-10-09
  • 2021-06-23
相关资源
相似解决方案