sno 语言 数学 英语
1 90 59 68
2 32 98 75
3 96 63 49
>=90优秀 >=60及格 <60不及格
no 语文 数学 英语
1 优秀 不及格 及格
2 不及格 优秀 及格
3 优秀 及格 不及格
------解决方案--------------------
试试这个:
--drop table t
create table t(sno int, 语文 Int, 数学 int, 英语 int)
insert into t
select 1 ,90 ,59 ,68 union all
select 2 ,32 ,98 ,75 union all
select 3 ,96 ,63 ,49
go
select sno,
case when 语文>=90 then '优秀' when 语文 >=60 then '及格' else '不及格' end 语文,
case when 数学>=90 then '优秀' when 数学 >=60 then '及格' else '不及格' end 数学,
case when 英语>=90 then '优秀' when 英语 >=60 then '及格' else '不及格' end 英语
from t
/*
sno 语文 数学 英语
1 优秀 不及格 及格
2 不及格 优秀 及格
3 优秀 及格 不及格
*/