这是我的查询,据我所知,它应该是正确的,除了我不确定如何合并表使用建筑物作为一个共同的领域。
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似乎不像我需要的那样工作
1条答案
按热度按时间9lowa7mx1#
如果你的查询抛出一个错误s.building doesn't exist,这肯定是因为在你的子查询中building列被别名为'BUILD',所以你应该在l.building和s.“BUILD”上连接。