Re: Functionally dependent columns in SELECT DISTINCT - Mailing list pgsql-general

From David G. Johnston
Subject Re: Functionally dependent columns in SELECT DISTINCT
Date
Msg-id CAKFQuwYEtU7doien_XGh58vjRdsJezXp2BQvKdLcyVZQwhLmgg@mail.gmail.com
Whole thread Raw
In response to Re: Functionally dependent columns in SELECT DISTINCT  (Willow Chargin <postgresql@wchargin.com>)
Responses Re: Functionally dependent columns in SELECT DISTINCT
List pgsql-general
On Friday, September 13, 2024, Willow Chargin <postgresql@wchargin.com> wrote:
In reality I really do want the ID columns of the
*most recent* items.

Use a window function to rank them and pull out rank=1, or use a lateral subquery to surgically (fetch first 1) retrieve the first row when sorted by recency descending.

David J. 

pgsql-general by date:

Previous
From: "Wong, Kam Fook (TR Technology)"
Date:
Subject: Will hundred of thousands of this type of query cause Parsing issue
Next
From: Willow Chargin
Date:
Subject: Re: Functionally dependent columns in SELECT DISTINCT