+ -
当前位置:首页 → 问答吧 → 写一个查询语句?

写一个查询语句?

时间:2011-12-13

来源:互联网

有一个学生成绩表,里面有各科的成绩,现在请查询并显示出学生姓名,科目名,及其学科状态(score>80[优秀],60<score<80[及格],score<60[不及格])。

作者: ghgaleno   发布时间: 2011-12-13

select 学生姓名,(case when 语文>=80 then '优秀'
when 语文>=60 then '及格'
else '不及格') as 语文,
(case when 数学>=80 then '优秀'
when 数学>=60 then '及格'
else '不及格') as 数学,
(case when 英语>=80 then '优秀'
when 英语>=60 then '及格'
else '不及格') as 英语,
from table

作者: huzhiqiang88   发布时间: 2011-12-13

SQL code

select 学生姓名,科目名,
case when score>=80 then '优秀'
when score>=60 and score<80 then '及格'
else '不及格' end as 学科状态
from 学生成绩表

作者: lxpbs8851   发布时间: 2011-12-13

热门下载

更多