关于SQL的条件查询及字段的显示转换
有一张表,里面有3个字段:语文,数学,英语。其中有3条记录分别表示语文70分,数学80分,英语58分,请用一条SQL语句查询出这三条记录并按以下条件显示出来(并写出您的思路):
大于或等于80表示优秀,大于或等于60表示及格,小于60分表示不及格。
SQL语句:
select
(case when 语文 >= 80 then ‘优秀’ when 语文 >= 60 and 语文 < 80 then ‘及格’ else ‘不及格’ end) as 语文,
(case when 数学 >= 80 then ‘优秀’ when 数学 >= 60 and 数学 < 80 then ‘及格’ else ‘不及格’ end) as 数学,
(case when 英语 >= 80 then ‘优秀’ when 英语 >= 60 and 英语 < 80 then ‘及格’ else ‘不及格’ end) as 英语
from tb_ceshi1;