Error: argument of AND must be type boolean, not type character varying
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
)
);
The part after the union is to include all partno from components that are not in productions (they should be counted as 0)
You have one bracket too many (after the
attr IS NULL) and you have an aggregate function (thecountin the second part) without agroup by. Do you mean this: