时间:2021-07-01 10:21:17 帮助过:11人阅读
求每一个同学的平均分
SELECT student,AVG(score) FROM score GROUP BY student
也能够依照 班级,课程 来求
查出挂了两门及以上的学生
SELECT student,SUM(score<60)as gk FROM score GROUP BY student HAVING gk>1
(1)where子查询
(把内层查询结果当作外层查询的比較条件)
求比每门课程平均分低的学生
SELECT student ,course, score
FROM score ,(SELECT course AS a_course,AVG( score)AS a_score FROM score GROUP BY course) AS avg_score
WHERE course = a_course AND score<a_score
先写到这吧
能够參考
http://www.cnblogs.com/rollenholt/archive/2012/05/15/2502551.html
mysql经常使用查询:group by,左连接,子查询,having where
标签:src html 互联网 表达 com sum logs 公司 archive