现在,当我计算注册日期时,我的查询给了我一个 0。我怎么会有一行显示“无”结果而不是 0。
我在这里想念什么?
COALESCE(TO_CHAR(SUM(ENROLLMENTS)),'none') ENROLLMENTS
这就是我所拥有的
SELECT lt.STUDENT_ID,lt.FIRST_NAME, lt.LAST_NAME,COALESCE(TO_CHAR(SUM(ENROLLMENTS)),'none') ENROLLMENTS
FROM STUDENT lt
LEFT OUTER JOIN
(SELECT s.STUDENT_ID, z.COURSE_NO,COUNT(e.ENROLL_DATE) AS ENROLLMENTS
FROM STUDENT s
LEFT JOIN ENROLLMENT e ON s.STUDENT_ID = e.STUDENT_ID
LEFT JOIN SECTION z ON e.SECTION_ID = z.SECTION_ID
WHERE s.PHONE LIKE '702%'
GROUP BY s.STUDENT_ID, z.COURSE_NO) rt
ON lt.STUDENT_ID = rt.STUDENT_ID
WHERE lt.PHONE LIKE '702%'
GROUP BY lt.STUDENT_ID,lt.FIRST_NAME, lt.LAST_NAME,ENROLLMENTS
ORDER BY lt.LAST_NAME,lt.FIRST_NAME;
而不是有结果
STUDENT_ID FIRST_NAME LAST_NAME ENROLLED
---------- ------------------------- ------------------------- -----------
253 Walter Boremmann 1
396 James E. Norman 0
etc
我想要这样
STUDENT_ID FIRST_NAME LAST_NAME ENROLLED
---------- ------------------------- ------------------------- -----------
253 Walter Boremmann 1
396 James E. Norman none
etc