public inbox for [email protected]  
help / color / mirror / Atom feed
Extract only maximum date from column
3+ messages / 2 participants
[nested] [flat]

* Extract only maximum date from column
@ 2025-12-05 12:16  Thiemo Kellner <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Thiemo Kellner @ 2025-12-05 12:16 UTC (permalink / raw)
  To: [email protected]

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








^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Extract only maximum date from column [RESOLVED]
@ 2025-12-05 16:04  Rich Shepard <[email protected]>
  parent: Thiemo Kellner <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Rich Shepard @ 2025-12-05 16:04 UTC (permalink / raw)
  To: [email protected]

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






^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Extract only maximum date from column [RESOLVED]
@ 2025-12-06 08:07  Thiemo Kellner <[email protected]>
  parent: Rich Shepard <[email protected]>
  0 siblings, 0 replies; 3+ messages in thread

From: Thiemo Kellner @ 2025-12-06 08:07 UTC (permalink / raw)
  To: [email protected]

Glad, to have been of assistance :-)


^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2025-12-06 08:07 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-12-05 12:16 Extract only maximum date from column Thiemo Kellner <[email protected]>
2025-12-05 16:04 ` Re: Extract only maximum date from column [RESOLVED] Rich Shepard <[email protected]>
2025-12-06 08:07   ` Re: Extract only maximum date from column [RESOLVED] Thiemo Kellner <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox