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