GROUP BY major_id) m
WHERE s.major_id = m.major_id
AND s.grade_point_avg > m.gpa_avg;
What will be the result of this SELECT statement?
A。 The names of all students with a grade point average that is higher than the average grade point average in their major will be displayed.
B。The names of all students with a grade point average that is higher than the average grade point average of all students will be displayed.
C。The names of all students with a grade point average that is higher than the average grade point average of all students in each major will be displayed.
D。A syntax error will be returned because the FROM clause CANNOT contain a subquery.
答案是A,为什么不选C
GROUP BY major_id) m
WHERE s.major_id = m.major_id
AND s.grade_point_avg > m.gpa_avg;
What will be the result of this SELECT statement?
A。 The names of all students with a grade point average that is higher than the average grade point average in their major will be displayed.
B。The names of all students with a grade point average that is higher than the average grade point average of all students will be displayed.
C。The names of all students with a grade point average that is higher than the average grade point average of all students in each major will be displayed.
D。A syntax error will be returned because the FROM clause CANNOT contain a subquery.
答案是A,为什么不选C [/B]
The last sentence "AND s.grade_point_avg>m.gpa_avg" has told you that will select the average grade point from student which is greater than the average grade point of major.You should check it carefully."s" means student and "m" means Major.Hope this can help you!!!
fsiukei ,thanks for your help.But I still wonder
"the average grade point average in their major"和
the average grade point average of all students in each major 有什么分别呢
英文比较绕口,我的理解是:
每门 major不是所有的students都报考的
比如 有的学生 选了 美术,但不是所有学生都选了这么课程,那么显然,这两句是有很大区别的
"the average grade point average in their major"--major的平均分,考这门课的所有学生,只计算部分学生,不是所有学生,假如所有学生 100人,考这么课是50人,那统计的就是50人
the average grade point average of all students in each major ,这句英语,应该是统计了所有的学生(包括没有参加这门专业考试的),统计的是100人
显然原查询select的是 前者
--SELECT major_id, AVG(grade_point_avg) gpa_avg FROM student m GROUP BY major_id