我有两张桌子;一个包含学生names
和另一个是包含和他们sids
的“接受”表。sids of students
grades
我想显示平均大于学生名字“Peter-Parker”的学生的名字。
我已经尝试了下面的查询,但它不起作用。
SELECT s.sid, s.fname, s.lname
FROM student s, take t
WHERE s.sid = t.sid AND AVG(t.grade) > ALL(
SELECT AVG(grade)
FROM take, student
WHERE student.fname = 'Ali' and student.lname='Demir');
WITH AliAv(avg) AS
(SELECT AVG(grade) from take t, student s
where t.sid = s.sid ands.fname = 'Ali' and s.lname = 'Demir')
select student.sid, student.fname, student.lname
from student, take
where student.sid = take.sid Group by student.sid
having avg(take.grade) > AliAv.av;