select *,[成绩]=(case when 分数<60 then '不及格' else '及格' end) from tb
select *,[成绩]=CAST((case when 分数<60 then '不及格' else '及格' end) AS NVARCHAR(10)) from tb
create table student ( stuNo int , stuName varchar(50), stuScore varchar(50) ) insert into student select 1,'a',90 union all select 2,'b',60 union all select 3,'c',40 select stuNo '学号',stuName '姓名',stuScore '分数', case when stuScore>60 then '及格' else '不及格' end '成绩' from student学号 姓名 分数 成绩 ----------- ------------------------------------------- 1 a 90 及格 2 b 60 不及格 3 c 40 不及格(3 行受影响)
create table student ( stuNo int , stuName varchar(50), stuScore varchar(50) ) insert into student select 1,'a',90 union all select 2,'b',60 union all select 3,'c',40
select stuNo '学号',stuName '姓名',stuScore '分数', case when stuScore>=60 then '及格' else '不及格' end '成绩' from student
学号 姓名 分数 成绩 ----------- ------------------------------------------- 1 a 90 及格 2 b 60 及格 3 c 40 不及格
(
stuNo int ,
stuName varchar(50),
stuScore varchar(50)
)
insert into student
select 1,'a',90 union all
select 2,'b',60 union all
select 3,'c',40 select stuNo '学号',stuName '姓名',stuScore '分数',
case when stuScore>60 then '及格'
else '不及格'
end '成绩'
from student学号 姓名 分数 成绩
----------- -------------------------------------------
1 a 90 及格
2 b 60 不及格
3 c 40 不及格(3 行受影响)
create table student
(
stuNo int ,
stuName varchar(50),
stuScore varchar(50)
)
insert into student
select 1,'a',90 union all
select 2,'b',60 union all
select 3,'c',40
select stuNo '学号',stuName '姓名',stuScore '分数',
case when stuScore>=60 then '及格'
else '不及格'
end '成绩'
from student
学号 姓名 分数 成绩
----------- -------------------------------------------
1 a 90 及格
2 b 60 及格
3 c 40 不及格
(3 行受影响)