所以我有这些表:
Student(Rollno,name,address)
Subject(sub_code,sub_name)
Marks(Rollno,sub_code, marks)
我想用名字显示标记的平均值。我使用此查询来查找标记的平均值:
SELECT Rollno,avg(marks) FROM MARKS GROUP BY Rollno;
如何获取相应卷号的名称?
答案 0 :(得分:2)
尝试使用联接:
SELECT M.Rollno, S.NAME, avg(M.marks)
FROM Marks AS M
JOIN Students AS S ON M.rollno = S.rollno
GROUP BY M.Rollno, S.NAME,;