Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vRYId-00G3oV-1i for pgsql-general@arkaria.postgresql.org; Fri, 05 Dec 2025 16:04:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vRYIa-008wCW-2Q for pgsql-general@arkaria.postgresql.org; Fri, 05 Dec 2025 16:04:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vRYIa-008wCO-1K for pgsql-general@lists.postgresql.org; Fri, 05 Dec 2025 16:04:48 +0000 Received: from mail.appl-ecosys.com ([50.126.108.78]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vRYIT-003Ikf-0l for pgsql-general@lists.postgresql.org; Fri, 05 Dec 2025 16:04:42 +0000 Received: from salmo.appl-ecosys.com (salmo.appl-ecosys.com [192.168.55.1]) by mail.appl-ecosys.com (Postfix) with ESMTP id DA3DF2A14D6 for ; Fri, 5 Dec 2025 08:04:40 -0800 (PST) Date: Fri, 5 Dec 2025 08:04:40 -0800 (PST) From: Rich Shepard To: pgsql-general@lists.postgresql.org Subject: Re: Extract only maximum date from column [RESOLVED] In-Reply-To: <1ad757c9-09d2-46fe-b3e0-2e09c85745dd@gelassene-pferde.biz> Message-ID: References: <1ad757c9-09d2-46fe-b3e0-2e09c85745dd@gelassene-pferde.biz> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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