错误:AND 的参数必须是布尔类型,而不是类型字符变化
SELECT
partno,
count(manufacturer)
FROM
components
WHERE
partno IN (SELECT partno FROM productions
WHERE
year = 2005
AND attr is NULL
)
GROUP BY partno
UNION
SELECT
partno,
count(manufacturer)
FROM components
WHERE
partno IN (SELECT partno FROM productions
WHERE
year = 2005
AND attr is NULL
)
GROUP BY partno
)
AND (
partno NOT IN (SELECT partno FROM components
)
);
union 之后的部分是包含所有不在生产中的组件的 partno(它们应该计为 0)