我试图在PostgreSQL中执行此查询
SELECT sum(No_of_Items) AS Total,
Name FROM All_Bills_of_POS
GROUP BY Name
HAVING MAX(Total)
ORDER BY Total DESC LIMIT 1";
但我有个错误:
org.postgresql.util.PSQLException:错误:HAVING的参数必须是boolean类型,而不是double precision类型
但是这个查询在SQLite中运行良好。如何在PostgreSQL中执行?
最佳答案
HAVING子句的计算结果不是布尔值。我想你需要这样的东西:
SELECT sum(No_of_Items) AS Total, Name
FROM All_Bills_of_POS
GROUP BY Name
HAVING MAX(Total) > 1
ORDER BY Total DESC
LIMIT 1
关于postgresql - 错误:HAVING的参数必须为 bool 类型,而不是 double 类型,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27542471/