On Sun, Oct 27, 2013 at 2:04 PM, Robert James <srobertjames@xxxxxxxxx> wrote:
I have a table (x,y,z) - I'd like to take the rows with unique x
values - but, when more than one row have the same x value, I want the
one with the minimal z value.
You can use distinct on (which is a Postgresql extension to the SQL standard):
select distinct on(x) x, y, z
from the_table
order by x, z
Regards
Marcin Mańk