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 1gtyLt-00012i-AJ for pgsql-general@arkaria.postgresql.org; Wed, 13 Feb 2019 17:29:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gtyLr-00077z-RQ for pgsql-general@arkaria.postgresql.org; Wed, 13 Feb 2019 17:29:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gtyLq-00077s-Ij for pgsql-general@lists.postgresql.org; Wed, 13 Feb 2019 17:29:39 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gtyLn-0008Nf-6a for pgsql-general@lists.postgresql.org; Wed, 13 Feb 2019 17:29:38 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 87F96300A for ; Wed, 13 Feb 2019 12:29:32 -0500 (EST) Received: from imap1 ([10.202.2.51]) by compute6.internal (MEProxy); Wed, 13 Feb 2019 12:29:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= message-id:in-reply-to:references:date:from:to:subject :content-type; s=fm2; bh=DH/uZtSTjeERRGj5zfGFJUY6kLegaS20/u1h5xl lT1U=; b=t/0zvY/Eb4PIYZZxSYjFHoOci2zNvZUwoMez7SNSLQ/PrxvQs3DIK7s vUsW7HW8FoDQxUqTbqgZlrDU16oyUoUBVJrqXIIW1i2zYGoQteRh1MhOiWOy7rQg NLikwPrMKk1NnZZa8mMfckS5wFE8aQCW7/+rxPKcVjqFcQJMAQnJoP25OPDhYY6/ pQmu+C4w0OwVuM/NXbKeyV5M+u+S0OZVx0dz9zAmeUESOtSc/hQxnaALbOa/EjFk liJmRY9wypnHNAWkbDt9tGVZTM87fIz/cXY2hILetGXIcuvBt5JpRU5Aipwo0yDR rKPanaDDQOhdDVHIbyZFkCksL0o8Ulg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:references:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=DH/uZtSTjeERRGj5z fGFJUY6kLegaS20/u1h5xllT1U=; b=f3NAbwgQYu6BhOX8pErxuYaCFiyjU9WQk 6P7tmmFLab16YKjZVxzfCoDhGfwMImA0MzmCK+5uXgfWYI3Z0jyTGLyg3Boe8SEX S3rGyfY4DRIFYttA8RThrXybXvsCzdrLjY34+XEdfzvNf3rKsxOW9e2Pj5qAoJnX /hH2PXp5gxf9x2zz1i+FPnpVDgQZXYjo6sDX2Rc9FJnCoi6AsMSVukyhN6c4lj7g 4Pj3Vsk/6FQ13TCNpWwU469DE2DWDAdtAxAB0KxL8AhpYV1PUM2OA0lQEhv3QMGg KwI41ju5qinVR8BD2+BC5AM4lgL9HSu3vrvuy49ZLl94SfS3rE95g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledruddtfedguddtfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucenucfjughrpefofgfkjghffffhvffutgesthdtredtreertdenucfhrhhomh epfdetughrihgrnhcumfhlrghvvghrfdcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhl rghvvghrrdgtohhmqeenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklh grvhgvrhesrghklhgrvhgvrhdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id D3D08D43B7; Wed, 13 Feb 2019 12:29:31 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.1.5-832-gba113d7-fmstable-20190201v1 X-Me-Personality: 20333377 Message-Id: In-Reply-To: References: <2780074d-3b87-b154-8bc6-a0f898fbdde2@openvistas.net> Date: Wed, 13 Feb 2019 12:29:25 -0500 From: "Adrian Klaver" To: pgsql-general@lists.postgresql.org Subject: Re: Subquery to select max(date) value Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, Feb 13, 2019, at 9:06 AM, Rich Shepard wrote: > On Wed, 13 Feb 2019, Adrian Klaver wrote: > > > Should have been clearer in my previous post, you can get rid of the nulls > > by filtering out the entire row. > > Adrian, > > Thank you. I'm rebuilding the statement from the inside out (which helps me > learn more SQL in the process). For example, > > select * from activities where next_contact is not null and > next_contact <= 'today' and next_contact > '2018-12-31'; > > works as written. This suggests that it's the placement within the two joins > that needs correcting. Now I'll add the two joined tables one at a time and > learn how to structure the whole statement. It will work if you use it to filter after the joins are done. > > Best regards, > > Rich > > >