Re: Extract only maximum date from column - Mailing list pgsql-general

From Rich Shepard
Subject Re: Extract only maximum date from column
Date
Msg-id 71e7ffd-2151-cf3c-b1d9-5b8d66bb9b6@appl-ecosys.com
Whole thread Raw
In response to Re: Extract only maximum date from column  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general
On Thu, 4 Dec 2025, David G. Johnston wrote:

> I would go with a lateral join subquery of the contracts table. Using an
> aggregates to perform ranking is an anti-pattern. You want the contract
> ranked first when ordered by contract_date. Either use a window function
> to explicitly rank the contracts or use a limit/fetch clause to simply
> return the first ordered one.

David,

It's 'contacts' rather than 'contracts'; a minor typo.

I'll read on making a lateral join. Thanks.

> You also seem to have completely missed joining people to contracts -
> suggest using explicit “join” clauses to make that error less likely.

Oops! My bad. Fixed.

Regards,

Rich



pgsql-general by date:

Previous
From: Rich Shepard
Date:
Subject: Re: Extract only maximum date from column
Next
From: Bryan Sayer
Date:
Subject: Re: Extract only maximum date from column