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 1gjTVA-0000G0-RM for pgsql-general@arkaria.postgresql.org; Tue, 15 Jan 2019 18:31:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gjTV9-0002tn-9L for pgsql-general@arkaria.postgresql.org; Tue, 15 Jan 2019 18:31:51 +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 1gjTV8-0002sg-QJ for pgsql-general@lists.postgresql.org; Tue, 15 Jan 2019 18:31:51 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gjTV2-00026Y-6R for pgsql-general@lists.postgresql.org; Tue, 15 Jan 2019 18:31:49 +0000 Received: by mail-pf1-x42c.google.com with SMTP id u6so1696767pfh.11 for ; Tue, 15 Jan 2019 10:31:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=GCM+y8rihfGyJItrGneEasFMhDqUc4ersrtjpL+DpQg=; b=ddfvVObFJzANM7kH92HSCPbxrUqEPUzIQT5bsxp4Jm1ntyLXlmbeYO/9G+Vxw29kkc VD1e0OkDpktkAGHp72ClcCsY6UJQUXVKXJ2d92M7J77VYhCVLoHteUzCtaDwrdINHWak Z72iM4H8S3pUSSRWLpX/LpoM0eijjyh4caOtG2oTlNqSonBLwHHJknyvwYYJnkLmWfMR +rstK6j1yvsvIumKIc9bP+JXWItUJOPr4udvGwsgTtjVjep3RBfnusD1eKn2TdP5/oxD cf+fQvCykIHWY3eLz9qwneZvcC2VLqIxvTG2gEyEgVTzQUk4G4x6gdiLE2/8jwy8OmsK czgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=GCM+y8rihfGyJItrGneEasFMhDqUc4ersrtjpL+DpQg=; b=sK56Y8qWfJjnqIHl4b/yfZotyLQpBJwbXzi/XWttm0SRdLR7DlrQGurtVn9zNJxHtI 8F89NoDh4s8tWwcCOL+EhhvRipBQCwK0JGiTEBqN6RmUV2w16dYu0tGgNSprz9a+alXK /fYNkEvMXz7AlW0YPNo+ECOABY96En06kgP0U6OnoSuz8gcm7O4MHBil5NEe0wWO0btI Nc/Z+JRPRZreywL9szqATRhmQJe7EyGnPNKgEKEw4EDlNzzlyh21qNp+hYh3P6G/q+7M kcOmGBInMDaCV6WIC2StLOQU+Ud6bZbIiQOKqDNlPYN+NGIdkn14bhcriw6VAInuTltK pbGg== X-Gm-Message-State: AJcUukfC7lpgowCgMZWV1Ypv1PQg2jh/SSEG6hnujJxlH3Bdyxew9H1v rSDEU+FDZ0t2BCmzuG3+Co8LwAEm X-Google-Smtp-Source: ALg8bN4KjounlVmgLgiGe7lJbJUf/lfjWqExWeRDgio7XZNn3e/Qm8iUKnoxd7MhnmbaZKd6fuAOVQ== X-Received: by 2002:a63:f615:: with SMTP id m21mr5090456pgh.428.1547577102544; Tue, 15 Jan 2019 10:31:42 -0800 (PST) Received: from [10.104.134.14] ([155.100.47.6]) by smtp.gmail.com with ESMTPSA id z10sm5149982pfg.120.2019.01.15.10.31.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jan 2019 10:31:41 -0800 (PST) Subject: Re: Refining query statement To: pgsql-general@lists.postgresql.org References: <9a5976c8-76da-f06d-9840-5dcf8723e38b@gmx.net> <26851021-69e3-36e4-170d-40ed7219a180@gmail.com> From: Rob Sargent Message-ID: <641fb2e0-fbaa-c477-e43d-e0bdaef6e19d@gmail.com> Date: Tue, 15 Jan 2019 11:31:40 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <26851021-69e3-36e4-170d-40ed7219a180@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 1/15/19 9:02 AM, Ron wrote: select distinct on (C.contact_id) C.contact_id, C.lname, C.fname, C.direct_phone, O.org_name, A.next_contact >>      from Contacts as C >>        join Organizations as O on C.org_id = O.org_id >>        join Activities as A on C.contact_id = A.contact_id >>      where A.next_contact <= 'today' >>        and A.next_contact > '2018-12-31' >>      order by c.contact_id, a.next_contact DESC; > > And I've never liked this method (though I'm old and crotchety).... > I suspect I can match your old and crotchety, but jump in, the water is fine (once you get used to it)