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 1gkByc-0007oR-An for pgsql-general@arkaria.postgresql.org; Thu, 17 Jan 2019 18:01:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gkBya-0000ZF-Ur for pgsql-general@arkaria.postgresql.org; Thu, 17 Jan 2019 18:01:12 +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 1gkBya-0000Xc-IN for pgsql-general@lists.postgresql.org; Thu, 17 Jan 2019 18:01:12 +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 1gkByY-0004nQ-3e for pgsql-general@lists.postgresql.org; Thu, 17 Jan 2019 18:01:11 +0000 Received: from salmo.appl-ecosys.com (salmo.appl-ecosys.com [192.168.55.1]) by mail.appl-ecosys.com (Postfix) with ESMTP id 1398899353 for ; Thu, 17 Jan 2019 10:01:09 -0800 (PST) Date: Thu, 17 Jan 2019 10:01:09 -0800 (PST) From: Rich Shepard To: pgsql-general@lists.postgresql.org Subject: Re: Refining query statement In-Reply-To: <7cbcfe0e-813e-b25e-f90e-dbf1e04f5076@aklaver.com> Message-ID: References: <9a5976c8-76da-f06d-9840-5dcf8723e38b@gmx.net> <7cbcfe0e-813e-b25e-f90e-dbf1e04f5076@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 Thu, 17 Jan 2019, Adrian Klaver wrote: > Seems to me a boolean field of name active to denote contacts you need to > keep up with is in order. Then make the next_contact field NOT NULL and > replace the current NULL values with 'infinity': > WHERE COALESCE(next_contact, 'infinity') BETWEEN '01/01/2019'::date AND > 'today'::date Adrian, Having added a new column, 'active' with boolean values (and a default of true), would this WHERE clause work: WHERE active = TRUE and next_contact <= 'today'::date ? Regards, Rich