Re: Grouping Too Closely - Mailing list pgsql-sql

From Greg Sabino Mullane
Subject Re: Grouping Too Closely
Date
Msg-id 7fdee0e68098da02600bf51be5a7f3f5@biglumber.com
Whole thread Raw
In response to Grouping Too Closely  ("Thomas F. O'Connell" <tfo@sitening.com>)
Responses Re: Grouping Too Closely
List pgsql-sql
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


> What I'd like to be able to do is select all records corresponding to
> the minimum value of seq1 for each value of seq2 corresponding to a
> given fkey (with a lower bound on the value of seq2).

I'm not sure how uid figures in, but would this do what you want?:

SELECT fkey, uid, seq2, min(seq1)
FROM my_table
WHERE seq2 > 2
GROUP BY fkey, uid, seq2
ORDER BY 1,2,3;

- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200506250019
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iD8DBQFCvNuWvJuQZxSWSsgRAhPZAJ9ssJx1/9x1Ngr9i/fThpKkDwMq1wCg5TW0
fKHUuoUBrXx+0/5hRegpXF4=
=obPq
-----END PGP SIGNATURE-----




pgsql-sql by date:

Previous
From: "Greg Sabino Mullane"
Date:
Subject: Re: people who buy A, also buy C, D, E
Next
From: "Thomas F. O'Connell"
Date:
Subject: Re: Grouping Too Closely