Re: [GENERAL] Unique - first

2013-10-27 Thread Marcin Mańk
On Sun, Oct 27, 2013 at 2:04 PM, Robert James 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

Re: [GENERAL] Unique - first

2013-10-27 Thread Rowan Collins
On 27/10/2013 13:04, Robert James 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. How can I do that? I can imagine doing it with window functions, but also that regular SQ

Re: [GENERAL] Unique - first

2013-10-27 Thread Tom Lane
Thomas Kellerer writes: > Robert James wrote on 27.10.2013 14:04: >> 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. >> >> How can I do that? I can imagine doing it with win

Re: [GENERAL] Unique - first

2013-10-27 Thread Thomas Kellerer
Robert James wrote on 27.10.2013 14:04: 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. How can I do that? I can imagine doing it with window functions, but also that regular SQL

[GENERAL] Unique - first

2013-10-27 Thread Robert James
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. How can I do that? I can imagine doing it with window functions, but also that regular SQL should be able to do it too. -- Sent v