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 1vRUov-00EXYt-1V for pgsql-general@arkaria.postgresql.org; Fri, 05 Dec 2025 12:21:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vRUos-007tIJ-3C for pgsql-general@arkaria.postgresql.org; Fri, 05 Dec 2025 12:21:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vRUos-007tHv-1t for pgsql-general@lists.postgresql.org; Fri, 05 Dec 2025 12:21:54 +0000 Received: from sm-r-018-dus.org-dns.com ([89.107.70.8]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vRUoq-003H6O-2y for pgsql-general@lists.postgresql.org; Fri, 05 Dec 2025 12:21:54 +0000 Received: from smarthost-dus.org-dns.com (localhost [127.0.0.1]) by smarthost-dus.org-dns.com (Postfix) with ESMTP id 46C26A108E for ; Fri, 5 Dec 2025 13:16:28 +0100 (CET) Received: by smarthost-dus.org-dns.com (Postfix, from userid 1001) id 3A4DEA10D3; Fri, 5 Dec 2025 13:16:28 +0100 (CET) X-Spam-Status: No, score=-0.3 required=5.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,DMARC_PASS,KAM_INFOUSMEBIZ,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 Received: from ha01s018.org-dns.com (ha01s018.org-dns.com [62.108.32.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smarthost-dus.org-dns.com (Postfix) with ESMTPS id EB147A108E for ; Fri, 5 Dec 2025 13:16:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gelassene-pferde.biz; s=default; t=1764936981; bh=meUH1bj6/kylKjM60l6+TN6mkz94pd6AHE4rpzenrRE=; h=From:Subject:To; b=NAC3RiSOC2gNc4JdZwonhURJeHa9W1lSX4XPpOAy9+HGghqxlp0xurUXqdcFFzfMO X1+5mvO2SN3cMkDkR51A0HhFkpaXsaIY653xLxCBSidUXQBciphqUM11nWchxW1HHX FXLGx244TZmCQLzhB2oHr3r/scptojO4Jo5crCeE= Authentication-Results: ha01s018.org-dns.com; spf=pass (sender IP is 146.185.68.202) smtp.mailfrom=thiemo@gelassene-pferde.biz smtp.helo=[192.168.178.42] Received-SPF: pass (ha01s018.org-dns.com: connection is authenticated) Message-ID: <1ad757c9-09d2-46fe-b3e0-2e09c85745dd@gelassene-pferde.biz> Date: Fri, 5 Dec 2025 13:16:20 +0100 MIME-Version: 1.0 From: Thiemo Kellner Subject: Extract only maximum date from column To: pgsql-general@lists.postgresql.org References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-PPP-Message-ID: <176493698161.1934270.2303370159037256497@ha01s018.org-dns.com> X-PPP-Vhost: gelassene-pferde.biz X-POWERED-BY: wint.global - AV:CLEAN SPAM:OK List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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