1. 程式人生 > >SQL 行轉列

SQL 行轉列

when sel student sco select score The sele then

1 select * from Score

技術分享圖片

1 select student,
2 sum(case course when ‘語文‘ then score end) as ‘語文‘,
3 sum(case course when ‘數學‘ then score end) as ‘數學‘,
4 sum(case course when ‘英語‘ then score end) as ‘英語‘
5 from Score 
6 group by student

技術分享圖片

SQL 行轉列