Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mGjG8-0004dY-U4 for pgsql-general@arkaria.postgresql.org; Thu, 19 Aug 2021 14:43:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mGjG7-0006Z1-Sk for pgsql-general@arkaria.postgresql.org; Thu, 19 Aug 2021 14:43:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mGjG6-0006YQ-Ik for pgsql-general@lists.postgresql.org; Thu, 19 Aug 2021 14:43:07 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mGjG2-0002K0-Bf for pgsql-general@lists.postgresql.org; Thu, 19 Aug 2021 14:43:06 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 07C965C00CC; Thu, 19 Aug 2021 10:42:58 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 19 Aug 2021 10:42:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=f x0hWSXDKF0a+lbtHupoHAMaHDDi75FV1tNqQbEc1cM=; b=jDW+NUzdbEianI7oc 6Rs4re2DQnJDzPJvi5ymT+dZzhTQRNQwKw+oUx2EjByyZFxHHFBcchVkQ4KcPDRs 18CczSaZ03qQilui4En+mJfCx2/JqlKmqCU6/J/2TZK1U3E//4rc+lB06rRt44UJ zs3Agl1xQdAESeAuU7WnZxpbmUtVL3YrVcxH/BsH16SwBNn4L++LWK7bMUK6RG1S MG+BgOTkQQXfmc34bStJyWlGU47TQgtcKagULYaZPpXeo2woQoyLA7ffyzG2pWe3 hoBOuKcZ6tVY7wfCXeZwKyuiLAh0I0PDmXFULt1d6+kMh7Rm9UENm1EHyWJeIf+o 616uQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=fx0hWSXDKF0a+lbtHupoHAMaHDDi75FV1tNqQbEc1 cM=; b=FSiIFW5uVPyOUcQJdz+Jns67ZAbFvb6MmwBuEKge0/w5rtgvwY3Gk7EBS ud/Hx+T96o0HIzJ36hj2yTvL3NylcZ72n2jFF+uA+ULX/dqUXKpM9MA91ZyJKzq/ N0Gtpa0zxNFJEceUAfxei3kmhOkpk8EnouT4MWBHODlPgqfJPtnp4LLMb5eQNmfy 74su3zkN9emUwpt6D2MR5ZUywefUnQwNQTYvytP8ndEBmJtCKkuIfoYual7i0dmO 0vQF39mXE1A3Qt32/ScHPf3TjhNRF+A0rJgYsH1AojSppxv/dJW1iHmVGKH3MJc/ pIZ68Z43wKw5BwTh9I4v2XMd1fb2Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrleejgdejkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecuggftrfgrthhtvghrnhepteejvdetffejuedvleeifeefheeutdfhgfdvhffhhfek vdduveegvdejudefgfevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 19 Aug 2021 10:42:58 -0400 (EDT) Subject: Re: Selecting table row with latest date To: Rich Shepard , pgsql-general@lists.postgresql.org References: From: Adrian Klaver Message-ID: <27de6c2f-4c60-5985-9b1e-469ae633ca1c@aklaver.com> Date: Thu, 19 Aug 2021 07:42:57 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 8/19/21 7:37 AM, Rich Shepard wrote: > I have a table of contacts (PK is the person_nbr and contact_date) and I > want to select only the row with the latest (most recent) contact_date. The > Comparison Date/Time sections in the postgres 12 doc doesn't appear to have > what I want, and when I try to use the max() aggregate function it > throws an > error. Show the query and the error you received. > > Please point me to the proper place in the docs where I can learn how to do > this. > > Rich > > > -- Adrian Klaver adrian.klaver@aklaver.com