将 SQLite 语句移植到 Firebird

Porting SQLite statement to Firebird

我有这个 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

如果你只需要从内部查询 count extra 最好不要 select 其他人和 group by 他们,因为你没有使用聚合无论如何功能(在内部查询中)。