Re: Functionally dependent columns in SELECT DISTINCT

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Willow Chargin <postgresql(at)wchargin(dot)com>
Cc: "shammat(at)gmx(dot)net" <shammat(at)gmx(dot)net>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Functionally dependent columns in SELECT DISTINCT
Date: 2024-09-13 15:43:54
Message-ID: CAKFQuwYEtU7doien_XGh58vjRdsJezXp2BQvKdLcyVZQwhLmgg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Friday, September 13, 2024, Willow Chargin <postgresql(at)wchargin(dot)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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Willow Chargin 2024-09-13 16:12:12 Re: Functionally dependent columns in SELECT DISTINCT
Previous Message Wong, Kam Fook (TR Technology) 2024-09-13 15:34:55 Will hundred of thousands of this type of query cause Parsing issue