赞
踩
3.查询各科成绩最高和最低的分, 以如下的形式显示:课程号,最高分,最低分
10.查询每门课程的平均成绩,结果按平均成绩升序排序,平均成绩相同时,按课程号降序排列
题目来源:知乎猴子 常见的SQL面试题:经典50题
- select *
- from student
- where sname like "猴%"
- select count(*)
- from teacher
- where tname like "孟%"
- select sum(score)
- from score
- where cid="0002"
- select count(distinct sid)
- from score
- where cid is not null and score is not null
- select cid, max(score),min(score)
- from score
- group by cid
- select cid,count(distinct sid)
- from score
- group by cid
- select ssex,count(sid)
- from student
- group by ssex
- select sid, avg(score) as average
- from score
- group by sid
- having average>60
- select sid,count(distinct cid)
- from score
- group by sid
- having count(distinct cid)>=2
- select sname, count(sid)
- from student
- group by sname
- having count(sid)>=2
- select distinct cid
- from score
- where score<60
- order by cid desc
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。