我对SQL有一个非常基本的问题。
关系模式:
我想列出所有参加过MATH的学生,以及他们的MATH班级平均值减去学生的数学分数
Select DINSTINCT S.Sname, (E.Mark - AVG (E.Mark))
From Student As S, Class As C
Where C.ClassName = 'MATH' AND S.Sid = C.Sid
我不知道如何做差异;我不认为这是对的;谁能告诉我如何解决这个问题?
答案 0 :(得分:3)
Select DISTINCT S.Sname, E.Mark - (SELECT AVG(E.Mark)
FROM Student
WHERE C.ClassName = 'MATH')
From Student As S, Class As C
Where C.ClassName = 'MATH' AND S.Sid = C.Sid