PostreSQL的特性是 aggregate functions,它通过在所有组行上运行谓词来过滤组。
例如,下表:
star_name | star_type | landed_upon
-----------+-----------+-------------
Mars | Planet | t
Venus | Planet | t
Rhea | Moons | f
Titan | Moons | t这个every()查询:
SELECT star_type, max(star_name) example, COUNT(*)
FROM stars
GROUP BY star_type
HAVING every (landed_upon = true);返回Planet组,但不返回Moons组,因为Rhea不满足Moons组中的landed_upon谓词:
star_type | example | count
-----------+---------+-------
Planet | Venus | 2
(1 row)对于PostgreSQL every()有等效的PostgreSQL运算符吗?
发布于 2015-06-12 13:06:10
可以使用func对象生成SQL函数。
.having(func.every(Star.landed_upon))会产生
HAVING EVERY(stars.landed_upon)https://stackoverflow.com/questions/30756284
复制相似问题