日期:2014-05-18  浏览次数:20414 次

求一条sql语句!特简单
scoid:课目、stid:学号、score:分数
返回以下两门或两门以上课目(scoid)分数(score)低于60分的,学生号(stid)
------
scoid       stid       score
1               1             40
2               1             50
3               1             60
4               2             40
5               2             51
6               2             60
7               3             40
8               3             52
9               3             60

------解决方案--------------------
要求:列出学生成绩两门或者两们以上低于60分的学生号的学生学号及平均成绩。
标准答案如下:
---
SELECT sc.stid '学号 ',st.stuname '姓名 ',avg(sc.score) '平均分 '
FROM score sc,student st
WHERE sc.score> 60 AND sc.stid=st.stid
GROUP BY sc.stid,st.stuname
HAVING count(*)> =2