Replying to myself because I forgot that both versions need the gp.value<4
check removed, not just the distinct on one... :(
On Mon, 3 Mar 2003, Stephan Szabo wrote:
> select a.id from ...
> where ...
> group by a.id
> having max(gp.value)<4;
>
> select id from
> (select distinct on (a.id) a.id, gp.value
> from ...
> where ... -- [minus the gp.value check]
> order by a.id, gp.value desc
> ) foo
> where value<4;