Extract only maximum date from column
Thiemo Kellner <thiemo@gelassene-pferde.biz>
From: Thiemo Kellner <thiemo@gelassene-pferde.biz>
To: pgsql-general@lists.postgresql.org
Date: 2025-12-05T12:16:20Z
Lists: pgsql-general
Hi
Am I missing something?
select p.person_nbr
,p.company_nbr
,max(c.next_contact) -- the lasted contact in the group
from people as p
inner join contacts as c
on p.contact_id = c.id -- assumed join condition
where c.next_contact >= '2025-11-01'
group by p.person_nbr -- the group for which the latest contact is wanted
,p.company_nbr
order by p.person_nbr
,p.company_nbr;
Kind regards
Thiemo