Re: Extract only maximum date from column [RESOLVED]

From: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Extract only maximum date from column [RESOLVED]
Date: 2025-12-05 16:04:40
Message-ID: a74e4e5b-7b12-3962-f7e3-382e5c75882b@appl-ecosys.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 5 Dec 2025, Thiemo Kellner wrote:

> Am I missing something?

Thiemo,

Nope. I was the one missing something:

select p.person_nbr, p.company_nbr, max(c.next_contact)
from people as p
inner join contacts as c
on p.person_nbr = c.person_nbr
where c.next_contact >= '2025-11-01'
group by p.person_nbr, p.company_nbr
order by p.person_nbr, p.company_nbr;

and,

person_nbr | company_nbr | max
------------+-------------+------------
226 | 736 | 2025-12-02
367 | 396 | 2026-01-06
464 | 2286 | 2025-11-05
465 | 702 | 2025-11-17
537 | 356 | 2025-11-03
553 | 367 | 2025-12-02
554 | 641 | 2025-12-02
...

Mea culpa!

Many thanks,

Rich

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Marcos Pegoraro 2025-12-05 16:47:58 Re: Frosen logical replication
Previous Message Rich Shepard 2025-12-05 13:41:44 Re: Extract only maximum date from column