On Tue, 24 Jan 2006, Alban Hertroys wrote: > This is sort of a feature request, I suppose. I solved my problem, but > "NOT HAVING" seems to match better with the desired result or the way > you phrase the question in your mind, if that makes any sense... One problem is that HAVING really works on entire groups at a time (including aggregated data for the group) not on pieces of the group. However, I think one might be able to fake it with an array accumulating aggregate like the one from http://www.postgresql.org/docs/current/static/xaggr.html and a query like: SELECT object_id FROM image GROUP BY object_id HAVING NOT(1 = ANY(array_accum(sort_order))).