Re: Unique - first

Поиск
Список
Период
Сортировка
От Marcin Mańk
Тема Re: Unique - first
Дата
Msg-id CAK61fk7b09NMdupaT1KYy+WdDJBqGVT6CH+=5JuKjfkFp+7nxg@mail.gmail.com
обсуждение исходный текст
Ответ на Unique - first  (Robert James <srobertjames@gmail.com>)
Список pgsql-general

On Sun, Oct 27, 2013 at 2:04 PM, Robert James <srobertjames@gmail.com> 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

В списке pgsql-general по дате отправления:

Предыдущее
От: Jayadevan M
Дата:
Сообщение: Re: search_path and current_schema
Следующее
От: anatoly techtonik
Дата:
Сообщение: Re: PGAdmin and user privileges - what I do wrong?