public inbox for [email protected]
help / color / mirror / Atom feedFrom: Laurenz Albe <[email protected]>
To: Bruno Wolff III <[email protected]>
To: Tom Lane <[email protected]>
Cc: [email protected]
Subject: Re: Can any_value be used like first_value in an aggregate?
Date: Wed, 26 Jun 2024 09:50:59 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
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
view thread (4+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: Can any_value be used like first_value in an aggregate?
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox