我目前的查询内容如下:
SELECT c.Course_No
, c.Description
, e.Section_Id
, COUNT(e.Section_ID) AS enrollment
FROM Enrollment e JOIN
Section s
ON e.Section_Id = s.Section_Id JOIN
Course c
ON s.Course_No = c.Course_No
Group by c.Course_No, c.Description, e.Section_Id
ORDER BY c.Course_No
它工作正常,以下是结果的片段:
COURSE_NO DESCRIPTION SECTION_ID ENROLLMENT
---------------------- -------------------------------------------------- ---------------------- ----------------------
10 Technology Concepts 80 1
20 Intro to Information Systems 81 3
20 Intro to Information Systems 82 2
20 Intro to Information Systems 83 2
20 Intro to Information Systems 84 2
我们的问题是:有没有办法合并具有相同课程描述和不同sectionID的字段?我希望将所有领域合并,但我不确定如何这样做。
添加提示和预期结果:生成一个字母列表,其中包含在第90节的期末考试中得分高于平均水平的学生的姓氏和期末考试成绩(FI)。
LAST_NAME NUMERIC_GRADE
------------------------- -------------
Da Silva 92
Lopez 91
答案 0 :(得分:1)
我想你想要这样的东西:
SELECT c.Course_No, c.Description,
LISTAGG(e.Section_Id, ',') WITHIN GROUP (ORDER BY e.Section_Id) as sections,
COUNT(*) AS enrollment
FROM Enrollment e JOIN
Section s
ON e.Section_Id = s.Section_Id JOIN
Course c
ON s.Course_No = c.Course_No
Group by c.Course_No, c.Description
ORDER BY c.Course_No