读书人

汇聚函数

发布时间: 2012-08-30 09:55:54 作者: rapoo

聚集函数
不能出现在where中

所以查出某些同学的数学分数大于平均分15分

select t1.namefrom student t1, course t2, student_course t3where t1.id = t3.student_id  and t2.id = t3.course_id  and t2.curse_name = 'Math'  and t3.score > 15 + (  select avg(t3.score)    from course t2, student_course t3   where t2.id = t3.course_id   and t2.curse_name = 'Math'  )

读书人网 >编程

热点推荐