我正在處理此任務,需要爲每個學生計算CGPA,以及Grades * credits /總學分公式。非法組功能SQL
select
round(sum((grade.grade*course.credits)/count(course.courseno)),1),
student.studentNo
from
course, grade, student, offering
where
student.studentno = grade.studentno
and course.courseno = offering.courseno
and offering.offerno = grade.offerno
group by
student.studentNo;
我有點卡住無法繼續,因爲我不知道這是什麼問題。
編輯:所以我做了一些更改爲你們指出,但即時通訊仍處於困境
select grade.studentno,
(select sum (t)
from(select(grade*credits)/count(offering.courseno)
from student s2, grade g2, offering o2, course c2
where s2.studentno=g2.studentno
and g2.offerno=o2.offerno
and o2.courseno=c2.courseno
group by g2.studentno
) t
)
from student, grade, offering, course
where student.studentno=grade.studentno
and grade.offerno=offering.offerno
and offering.courseno=course.courseno
group by grade.studentno;
錯誤
編號1054:在「字段列表」
未知列offering.courseno
它無法識別'count'子查詢中的聚合
您不能只使用'AVG(grade.grade * course.credits)'? –
[踢壞的習慣:使用舊式JOIN](http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/08/bad-habits-to-kick-using-old-style-joins。 aspx) - 在ANSI - ** 92 ** SQL標準(** 25年**之前!)中,舊式*逗號分隔的表*樣式列表被替換爲* proper * ANSI'JOIN'語法並且不鼓勵使用 –