我在 Oracle 11g 数据库上。
询问:
SELECT s.id, s.grade_level,
((1990+substr(sg.termid,1,2))||'-'||(1991+substr(sg.termid,1,2))) as "School Year",
SUM(sg.earnedcrhrs) as "Credits"
FROM students s
JOIN storedgrades sg ON s.id = sg.studentid
WHERE s.schoolid = 109
AND s.id = '3466'
AND s.enroll_status = 0
AND sg.schoolid = 109
GROUP BY ROLLUP(s.id, s.grade_level, substr(sg.termid,1,2))
ORDER BY s.id, substr(sg.termid,1,2)
输出:
有没有办法可以编写我的查询,以便不产生第 5 行或第 6 行?每个学生我只需要一个小计(ID 列)。