Re: Extract only maximum date from column
Rich Shepard <rshepard@appl-ecosys.com>
From: Rich Shepard <rshepard@appl-ecosys.com>
To: "pgsql-general@postgresql.org" <pgsql-general@postgresql.org>
Date: 2025-12-05T13:41:44Z
Lists: 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