STS又一题目,请教??

[复制链接]
查看11 | 回复6 | 2005-2-28 12:57:00 | 显示全部楼层 |阅读模式
Question:
Evaluate this SELECT statement:
SELECT s.student_name, s.grade_point_avg, s.major_id, m.gpa_avg
FROMstudent s, (SELECTmajor_id, AVG(grade_point_avg) gpa_avg

FROM student m

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
回复

使用道具 举报

千问 | 2005-2-28 12:57:00 | 显示全部楼层
好漂亮的照片,本来相帮你一把,可我不会,还没考这门
回复

使用道具 举报

千问 | 2005-2-28 12:57:00 | 显示全部楼层
最初由 on323 发布
[B]Question:
Evaluate this SELECT statement:
SELECT s.student_name, s.grade_point_avg, s.major_id, m.gpa_avg
FROMstudent s, (SELECTmajor_id, AVG(grade_point_avg) gpa_avg

FROM student m

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!!!
回复

使用道具 举报

千问 | 2005-2-28 12:57:00 | 显示全部楼层
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 有什么分别呢
回复

使用道具 举报

千问 | 2005-2-28 12:57:00 | 显示全部楼层
I also want to know ??
回复

使用道具 举报

千问 | 2005-2-28 12:57:00 | 显示全部楼层
英文比较绕口,我的理解是:
每门 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
回复

使用道具 举报

千问 | 2005-2-28 12:57:00 | 显示全部楼层
明白了,谢谢
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行