我正在尝试从其他表中其他表中列的平均值的表中进行选择;架构如下。
学生( sid
, firstname
, l astname
, status
, gpa
, email
)
注册( sid
, classid
, lgrade
)
成绩( lgrade
, ngrade
)
错误的查询是,
select sid, lastname,
avg( select g.ngrade from grades g, enrollments e
where e.sid = sid and g.lgrade = e.lgrade and e.lgrade is not null
and g.ngrade is not null) as cgpa
from students
order by cgpa asc;