1:对列进行逻辑判断
select ID,Score,
case
 when Score>=90 then 'A'
 when Score>=80 then 'B'
 when Score>=70 then 'C'
 when Score>=60 then 'D'
 when Score>=50 then 'E'
  end
from dbo.Scores

  

 
2:列转行
如果列名车位,某某,那么分数列
select stuNo,
sum(case when Subject='生物' then Score end) as 生物,
sum(case when Subject='数学' then Score end) as 数学,
sum(case when Subject='英语' then Score end) as 英语,
sum(case when Subject='语文' then Score end) as 语文
  from dbo.Scores group by StuNo

  

 

相关文章:

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