sql 已有现表,成绩分类成不及格中等良好优秀,,,在线等急!!!

2025-03-09 23:25:00
推荐回答(2个)
回答1:


select name, if(score<60, '不及格', if(score<75, '中等', if(score<85,'良好', '优秀'))) as rank from students;


后面需要分类操作可以使用group by 对rank项目进行操作

回答2:

score 代表成绩栏位

select case
when score < 60 then
'不及格'
when score>60 and score<=80 then
'中等'
when score>80 and score<=90 then
'良好'
else
'优秀'
end
from 现表