Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gth4M-00069R-IQ for pgsql-general@arkaria.postgresql.org; Tue, 12 Feb 2019 23:02:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gth4L-0006Z3-2Z for pgsql-general@arkaria.postgresql.org; Tue, 12 Feb 2019 23:02:25 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gth4K-0006Yw-Mw for pgsql-general@lists.postgresql.org; Tue, 12 Feb 2019 23:02:24 +0000 Received: from mail.appl-ecosys.com ([50.126.108.78]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gth4I-0005lm-4C for pgsql-general@lists.postgresql.org; Tue, 12 Feb 2019 23:02:23 +0000 Received: from salmo.appl-ecosys.com (salmo.appl-ecosys.com [192.168.55.1]) by mail.appl-ecosys.com (Postfix) with ESMTP id 1CB6E99356 for ; Tue, 12 Feb 2019 15:02:20 -0800 (PST) Date: Tue, 12 Feb 2019 15:02:20 -0800 (PST) From: Rich Shepard To: pgsql-general@lists.postgresql.org Subject: Re: Subquery to select max(date) value In-Reply-To: <8b99480a-7711-694e-a1c5-ae65bb0c0364@aklaver.com> Message-ID: References: <2780074d-3b87-b154-8bc6-a0f898fbdde2@openvistas.net> <8b99480a-7711-694e-a1c5-ae65bb0c0364@aklaver.com> User-Agent: Alpine 2.20 (LNX 67 2015-01-07) 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: Precedence: bulk On Tue, 12 Feb 2019, Adrian Klaver wrote: > 'infinity' is the max date, so this is what you want? Adrian, Nope. When I went to make a cup of coffee I realized that I need the other date constraints (such as IS NOT NULL), too. I'm re-wording the statement to put everything in the correct order. Will probably try DISTINCT ON, too, if that makes it simpler or faster. Thanks, Rich