public inbox for [email protected]
help / color / mirror / Atom feedFrom: Bruno Wolff III <[email protected]>
To: Laurenz Albe <[email protected]>
Cc: Tom Lane <[email protected]>
Cc: [email protected]
Subject: Re: Can any_value be used like first_value in an aggregate?
Date: Thu, 27 Jun 2024 08:06:29 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
On Wed, Jun 26, 2024 at 09:50:59 +0200,
Laurenz Albe <[email protected]> wrote:
>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;
That approach worked for that part of the query. Thanks.
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