oracle 我试图将空值显示为零,我如何将这些表连接在一起?

nafvub8i  于 2023-04-05  发布在  Oracle
关注(0)|答案(1)|浏览(150)

这是我的查询,据我所知,它应该是正确的,除了我不确定如何合并表使用建筑物作为一个共同的领域。

SELECT l.building AS "BUILD", NVL(NUMSECTIONS, 0) AS "NUMSECTIONS"
FROM location l
LEFT OUTER JOIN 
    (SELECT building AS "BUILD", COUNT(*) AS "NUMSECTIONS"
    FROM location l
    INNER JOIN sections e
    ON l.locationid = e.locationid
    INNER JOIN courses c
    ON e.courseid = c.courseid
    WHERE subjectcode IN ('CS', 'NET', 'WEB', 'MATH', 'ENGL', 'HIST', 'ZOOL', 'ART', 'COMM', 'BSAD')
    GROUP BY building)s
ON l.building = s.building

将内部表中的建筑物指定为s.building似乎不像我需要的那样工作

9lowa7mx

9lowa7mx1#

如果你的查询抛出一个错误s.building doesn't exist,这肯定是因为在你的子查询中building列被别名为'BUILD',所以你应该在l.building和s.“BUILD”上连接。

相关问题