Re: Can any_value be used like first_value in an aggregate?
В списке pgsql-general по дате отправления:
| От | Laurenz Albe |
|---|---|
| Тема | Re: Can any_value be used like first_value in an aggregate? |
| Дата | |
| Msg-id | 3998e51e47ce6b00c690cabfe4c60004ba42d8eb.camel@cybertec.at обсуждение исходный текст |
| Ответ на | Re: Can any_value be used like first_value in an aggregate? (Bruno Wolff III <bruno@wolff.to>) |
| Ответы |
Re: Can any_value be used like first_value in an aggregate?
|
| Список | pgsql-general |
On Tue, 2024-06-25 at 14:11 -0500, Bruno Wolff III wrote:
> The actual
> use case is a set of tripplets returned from a query, where I want on
> row for each distinct value in the first column, paired with the value
> in the second column, for which the third column is the largest. The
> second and third columns are effectively dependent on each other, so there
> won't be any ambiguity.
Try
SELECT DISTINCT ON (first_column)
first_column,
second_column,
third_column
FROM the_table
ORDER BY first_column, third_column DESC;
Yours,
Laurenz Albe
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера