错误:AND的参数必须为 bool 型,且不能改变字符类型
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
)
);
合并后的零件将包括生产中未使用的零件的所有零件号(它们应计为0)
最佳答案
您的括号过多(在attr IS NULL
之后),并且您有一个聚合函数(第二部分中的count
)而没有group by
。你的意思是:
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;
关于sql - 在where子句中使用 "AND"时出现错误 "argument must be type boolean",我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12686193/