When using "AND" in where clause get error "argument must be type boolean"
postgresql, sql
Solution
You have one bracket too many (after the `attr IS NULL`) and you have an aggregate function (the `count` in the second part) without a `group by`. Do you mean this:
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
)
AND partno not in (select partno from components)
group by partno;
Problem
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)