我有一张桌子“书”。为简单起见,这里有 3 列:
name(text) | new(boolean) | press(text)
我需要选择新书最多的出版社(出版社)。我不明白为什么 Access 显示“语法错误”。
SELECT press, COUNT(new) AS [Number of new books]
FROM books
WHERE new = TRUE
GROUP BY press
HAVING COUNT(new) =
SELECT MAX(s)
FROM
( SELECT COUNT(new) AS s, press
FROM books
WHERE new = TRUE
GROUP BY press
)
如果我只写第二部分:
SELECT MAX(s)
FROM
( SELECT COUNT(new) AS s, press
FROM books
WHERE new = TRUE
GROUP BY press
)
它返回正确的值 (5)
如果我只写有条件的第一部分= 5
,那很好。
SELECT press, COUNT(new) AS [Number of new books]
FROM books
WHERE new = TRUE
GROUP BY press
HAVING COUNT(new) = 5
我究竟做错了什么?