How to select rows that are the max for each subcategory?

Поиск
Список
Период
Сортировка
От Kynn Jones
Тема How to select rows that are the max for each subcategory?
Дата
Msg-id c2350ba40809251101y81de3f8qb0e5daafeaad240f@mail.gmail.com
обсуждение исходный текст
Ответы Re: How to select rows that are the max for each subcategory?
Re: How to select rows that are the max for each subcategory?
Список pgsql-general
Suppose I have a table T that has, among its columns, the fields X and Y, where Y is an integer, and multiple rows with the same value of X are possible.  I want to select the rows corresponding to the greatest values of Y for each value of X.  E.g. suppose that T is

X Y Z
a  1 eenie
a  3 meenie
a  2 miny
b  4 moe
b  0 catch

...the result of the desired query would be

a  3 meenie
b  4 moe

TIA!

Kynnjo



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

Предыдущее
От: "Pavel Stehule"
Дата:
Сообщение: Re: Dynamically created cursors vanish in PLPgSQL
Следующее
От: "Harald Armin Massa"
Дата:
Сообщение: Re: How to select rows that are the max for each subcategory?