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 841faf53-7f95-18b6-35-71516db8ca1e@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:

>> So:
>> Select person.*, lastcontact.*
>> from people
>> join lateral (select contacts.*
>>      from contacts
>>      where contacts.person_nbr = people.person_nbr
>>      order by last_contact_date
>>      desc limit 1)
>> as lastcontact on true;

> I was giving you a query form. You should use the actual table and column
> names in your schema…

David,

The two table names are 'people' and 'contacts', the columns are
'person_nbr' and 'last_contact.' I usually use aliases rather than the table
name to reference the column.

Rich



pgsql-general by date:

Previous
From: Thiemo Kellner
Date:
Subject: Extract only maximum date from column
Next
From: Rich Shepard
Date:
Subject: Re: Extract only maximum date from column [RESOLVED]