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 1vRFmN-00AT1u-2G for pgsql-general@arkaria.postgresql.org; Thu, 04 Dec 2025 20:18:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vRFmL-004glr-29 for pgsql-general@arkaria.postgresql.org; Thu, 04 Dec 2025 20:18:17 +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 1vRFmL-004glj-15 for pgsql-general@lists.postgresql.org; Thu, 04 Dec 2025 20:18:17 +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 1vRFmJ-0039yb-0v for pgsql-general@postgresql.org; Thu, 04 Dec 2025 20:18:16 +0000 Received: from salmo.appl-ecosys.com (salmo.appl-ecosys.com [192.168.55.1]) by mail.appl-ecosys.com (Postfix) with ESMTP id BBD482A14D6 for ; Thu, 4 Dec 2025 12:18:14 -0800 (PST) Date: Thu, 4 Dec 2025 12:18:14 -0800 (PST) From: Rich Shepard To: pgsql-general@postgresql.org Subject: Re: Extract only maximum date from column In-Reply-To: Message-ID: <41346178-2096-8b3a-42d2-1b60a1edb8d@appl-ecosys.com> References: MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 4 Dec 2025, Ron Johnson wrote: > May not be the only way, but it's how I do it: > SELECT * > FROM foo > WHERE some_dt = (SELECT MAX(some_dt) FROM foo); > > It might return more than one row... Ron, Didn't quite work for me this way: select p.person_nbr, p.company_nbr, c.next_contact from people as p, contacts as c where c.next_contact (select max(c.next_contact) from c.contacts) >= '2025-11-01' group by p.person_nbr, p.company_nbr order by p.person_nbr, p.company_nbr; Thanks, Rich