创建表:
CREATE TABLE [dbo].[course] (
[chinese] [float] NULL ,
[maths] [float] NULL ,
[english] [float] NULL ,
[id] [int] IDENTITY (1, 1) NOT NULL
) ON [PRIMARY]
insert into course (chinese,maths,english ) values (90,67,65)
要求当 >80 优秀,小于60 不及格,其他及格
Chinese | maths | english |
优秀 | 及格 | 及格 |
select
case when c.chinese >'80 ' then '优秀'
when c.chinese >60 and c.chinese < 80 then '及格'
when c.chinese < 60 then '不及格'
end as 'chinese'
,
case
when c.maths >'80 ' then '优秀'
when c.maths >60 and c.maths < 80 then '及格'
when c.maths < 60 then '不及格'
end as 'maths'
,
case
when c.english >'80 ' then '优秀'
when c.english >60 and c.english < 80 then '及格'
when c.english < 60 then '不及格'
end as 'english'
from course c