
case when语句
select 语文 ,
(case 语文
when 语文>=80 then '优秀'
when 语文>=60 and 语文<80 then '及格'
when 语文<60 then '不及格'
end) as 语文是否合格,
数学,
(case 数学
when 数学>=80 then '优秀'
when 数学>=60 and 语文<80 then '及格'
when 数学<60 then '不及格'
end) as 数学是否合格,
英语,
(case 英语
when 英语>=80 then '优秀'
when 英语>=60 and 英语<80 then '及格'
when 英语<60 then '不及格'
end) as 英语是否合格,
from 成绩表 where
呵呵,你这是一堆的问题呀:
优秀、良好……各级别的(人数):
首先,假设你的分数是 百分制,优秀即高于85分等。。。。
因此:
select 课程,count() as 人数,‘优秀’ as 类别
from 成绩
where 分数>85
group by 课程
union
select 课程,count() as 人数,‘良好’ as 类别
from 成绩
where 分数>70 and 分数<=85
group by 课程
union
select 课程,count() as 人数,‘及格’ as 类别
from 成绩
where 分数>60 and 分数<=70
group by 课程
分布情况及百分比:
得根据上面的结果来再计算。
先弄个总人数的视图:select count() as 总人数 from 成绩
再计算百分比:
select 课程,人数/总人数100% as 百分比 from 各级别人数 group by 课程,类别
其他的统计也就雷同了。
max(),avg(),sum(),case when 分数> then hege when 分数< then bu hege end as jibie from group by
以上就是关于有一张成绩表,里面有3个字段:语文,数学,英语。请用一条sql语句查询出 sql 大于60及格 小于60分不及格全部的内容,包括:有一张成绩表,里面有3个字段:语文,数学,英语。请用一条sql语句查询出 sql 大于60及格 小于60分不及格、sql查询问题 查询成绩分布情况、mysql查出每个班的最高分总分平均分,以及每门科目的总分,显示每个学生成绩合格或不合格等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)