用SQL语言找出每个学生超过他自己平均成绩的学号和课 10
设有关系学生(学号,姓名,年龄,院系)、课程(课程号,课程名,先行课)和选课(学号,课程号,成绩),试用SQL语言找出每个学生超过他自己平均成绩的学号和课程号一定要保证答...
设有关系学生(学号,姓名,年龄,院系)、课程(课程号,课程名,先行课)和选课(学号,课程号,成绩),试用SQL语言找出每个学生超过他自己平均成绩的学号和课程号
一定要保证答案的正确性,对了再加分! 展开
一定要保证答案的正确性,对了再加分! 展开
1个回答
展开全部
SELECT dbo.student.id, dbo.student.name, dbo.student.age, dbo.student.class, dbo.curriculum.id AS Expr1, dbo.curriculum.name AS Expr2, dbo.curriculum.Firstclass,
dbo.Elective.score, Table1.avgscore
FROM dbo.student LEFT OUTER JOIN
dbo.Elective ON dbo.student.id = dbo.Elective.id LEFT OUTER JOIN
dbo.curriculum ON dbo.Elective.curriculumid = dbo.curriculum.id RIGHT OUTER JOIN
(SELECT id, AVG(score) AS avgscore
FROM dbo.Elective AS Elective_1
GROUP BY id) AS Table1 ON Table1.id = dbo.student.id AND dbo.Elective.score >= Table1.avgscore
dbo.Elective.score, Table1.avgscore
FROM dbo.student LEFT OUTER JOIN
dbo.Elective ON dbo.student.id = dbo.Elective.id LEFT OUTER JOIN
dbo.curriculum ON dbo.Elective.curriculumid = dbo.curriculum.id RIGHT OUTER JOIN
(SELECT id, AVG(score) AS avgscore
FROM dbo.Elective AS Elective_1
GROUP BY id) AS Table1 ON Table1.id = dbo.student.id AND dbo.Elective.score >= Table1.avgscore
追问
这是神马玩意!表示看不懂
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询