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 1gkBc2-0006k3-Jr for pgsql-general@arkaria.postgresql.org; Thu, 17 Jan 2019 17:37:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gkBc1-00084Z-5i for pgsql-general@arkaria.postgresql.org; Thu, 17 Jan 2019 17:37:53 +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 1gkBc0-0007x9-6O for pgsql-general@lists.postgresql.org; Thu, 17 Jan 2019 17:37:52 +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 1gkBbx-0004BJ-3f for pgsql-general@lists.postgresql.org; Thu, 17 Jan 2019 17:37:50 +0000 Received: from salmo.appl-ecosys.com (salmo.appl-ecosys.com [192.168.55.1]) by mail.appl-ecosys.com (Postfix) with ESMTP id BB91C99353 for ; Thu, 17 Jan 2019 09:37:46 -0800 (PST) Date: Thu, 17 Jan 2019 09:37:46 -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: > To be clear the next-activity date = next_contact in the database, correct? Adrian, Yes. I've renamed the Activities table to Contacts and the Contacts table to People. > NULL basically means unknown, so having it stand for something is a bit of > a stretch. 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': This makes good sense. > As to current situation: > > 1) Use my previous suggestion. I did so, but will modify it as you suggest: > 2) WHERE COALESCE(next_contact, 'infinity') BETWEEN '01/01/2019'::date AND > 'today'::date Thanks again, Rich