语句1
select mark_avg from t_student
结果1
mark_avg
107
110
85
70
语句2
select mark_avg,
(case
when mark_avg >=90 then '优秀'
when mark_avg <90 and mark_avg >=80 then '良好'
when mark_avg <80 and mark_avg >=70 then '中等'
when mark_avg <70 and mark_avg >=60 then '较差'
when mark_avg <60 then '不及格'
else '' end)dj
from t_student
语句3
select mark_avg,
(case
when mark_avg >=90 then '优秀'
when mark_avg between 89 and 80 then '良好'
when mark_avg between 79 and 70 then '中等'
when mark_avg between 69 and 60 then '需努力'
when mark_avg <60 then '不及格'
else '' end)dj
from t_student
结果2
mark_avg dj
107 优秀
110 优秀
85 良好
70 中等
结果3
107 优秀
110 优秀
85
70
结果2和结果3居然不一致????
7 个解决方案
#1
发错图片了,怎么发了这么个东西???????????????????????
#2
#3
有点想不通,难道between and 不能用在case里面?
#4
when mark_avg between 89 and 80 then '良好'
when mark_avg between 79 and 70 then '中等'
when mark_avg between 69 and 60 then '需努力'
between MinValue and MaxValue , 小值在前,大值在后,你写反了。
#5
啊?我去试试。
#6
是不是范围区间的最大值和最小值颠倒了,试试下面这样呢。
when mark_avg between 80 and 89 then '良好'
when mark_avg between 70 and 79 then '中等'
when mark_avg between 80 and 89 then '良好'
when mark_avg between 70 and 79 then '中等'
#7
果然是这样,谢谢哈。晕了。
#1
发错图片了,怎么发了这么个东西???????????????????????
#2
#3
有点想不通,难道between and 不能用在case里面?
#4
when mark_avg between 89 and 80 then '良好'
when mark_avg between 79 and 70 then '中等'
when mark_avg between 69 and 60 then '需努力'
between MinValue and MaxValue , 小值在前,大值在后,你写反了。
#5
啊?我去试试。
#6
是不是范围区间的最大值和最小值颠倒了,试试下面这样呢。
when mark_avg between 80 and 89 then '良好'
when mark_avg between 70 and 79 then '中等'
when mark_avg between 80 and 89 then '良好'
when mark_avg between 70 and 79 then '中等'
#7
果然是这样,谢谢哈。晕了。