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 1vRW4D-00EsyW-2A for pgsql-general@arkaria.postgresql.org; Fri, 05 Dec 2025 13:41:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vRW4C-0088wJ-0e for pgsql-general@arkaria.postgresql.org; Fri, 05 Dec 2025 13:41:48 +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 1vRW4B-0088w9-2J for pgsql-general@lists.postgresql.org; Fri, 05 Dec 2025 13:41: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 1vRW49-003His-1i for pgsql-general@postgresql.org; Fri, 05 Dec 2025 13:41:47 +0000 Received: from salmo.appl-ecosys.com (salmo.appl-ecosys.com [192.168.55.1]) by mail.appl-ecosys.com (Postfix) with ESMTP id D51AC2A14D6 for ; Fri, 5 Dec 2025 05:41:44 -0800 (PST) Date: Fri, 5 Dec 2025 05:41:44 -0800 (PST) From: Rich Shepard To: "pgsql-general@postgresql.org" Subject: Re: Extract only maximum date from column In-Reply-To: Message-ID: <841faf53-7f95-18b6-35-71516db8ca1e@appl-ecosys.com> References: <54638724-615f-52f-29a6-74e2567b9599@appl-ecosys.com> <759515ff-7393-d28f-d627-6f4a48c11f4@appl-ecosys.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8BIT List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 4 Dec 2025, David G. Johnston wrote: >> So: >> Select person.*, lastcontact.* >> from people >> join lateral (select contacts.* >> from contacts >> where contacts.person_nbr = people.person_nbr >> order by last_contact_date >> desc limit 1) >> as lastcontact on true; > I was giving you a query form. You should use the actual table and column > names in your schema… David, The two table names are 'people' and 'contacts', the columns are 'person_nbr' and 'last_contact.' I usually use aliases rather than the table name to reference the column. Rich