我有这个 select 语句在 SQLite 中完美运行:
SELECT extra, count(extra) AS total FROM (SELECT itemID, item, note, sourceItemID, title, collectionName, tagID, modalityID, extra FROM items INNER JOIN factors ON items.itemID = factors.zotero_itemID WHERE collectionID = :collectionID AND (tagID = 4 OR tagID = 1) GROUP BY item) GROUP BY extra
但是当我尝试在 Firebird 上运行它时,我收到此错误消息:
Dynamic SQL Error.
SQL error code = -104.
Invalid expression in the select list (not contained in either an aggregate function or the GROUP BY clause).
请问有人可以告诉我发生了什么事吗? 最好的问候
最佳答案
SELECT extra, count(extra) AS total
FROM (SELECT extra
FROM items
INNER JOIN factors ON items.itemID = factors.zotero_itemID
WHERE collectionID = :collectionID
AND (tagID = 4 OR tagID = 1)
) t
GROUP BY extra
如果您只需要从内部查询中计数
额外
,最好不要选择其他查询并按它们分组
,因为您无论如何都不使用聚合函数(在内部查询中)。
关于sql - 将 SQLite 语句移植到 Firebird,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33684097/