5
Student(studentid,name,age)
Course(coursename,dept)
enroll(studentid,coursename,grade)
我需要編寫SQL找學生姓名與從歷史和政治科學系所學課程的最大等級各年齡組。
我嘗試迄今已
SELECT
name
FROM
student
GROUP BY age
HAVING sid IN
(
SELECT
max(grade)
FROM
enroll e,enroll e1
WHERE
e.studentid = e1.studentid
AND e.coursename = (
SELECT coursename FROM course
WHERE
dname like '%History%'
)
AND e1.coursename = (
SELECT coursename FROM course
WHERE
dname like '%PoliticalScience%'
)
)
你如何定義年齡組? – vikiiii
我的猜測是年齡組指向同一年齡段的學生,因此按年齡分組。 – user1675198