From: Rich Shepard <rshepard@appl-ecosys.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Refining query statement
Date: Thu, 17 Jan 2019 16:04:45 -0800 (PST)
Message-ID: <alpine.LNX.2.20.1901171559400.18965@salmo.appl-ecosys.com> (raw)
In-Reply-To: <fad7d8c4-0954-97dc-eff6-a8d1942f8dc4@aklaver.com>
References: <alpine.LNX.2.20.1901150738320.5845@salmo.appl-ecosys.com>
<9a5976c8-76da-f06d-9840-5dcf8723e38b@gmx.net>
<alpine.LNX.2.20.1901170759560.13573@salmo.appl-ecosys.com>
<68ed1eaa-7a03-fbaf-26e2-a1979b636174@aklaver.com>
<alpine.LNX.2.20.1901171424280.18965@salmo.appl-ecosys.com>
<fad7d8c4-0954-97dc-eff6-a8d1942f8dc4@aklaver.com>
On Thu, 17 Jan 2019, Adrian Klaver wrote:
> I would think the active would be on People or Organizations. Then you can
> eliminate then from the query results before you ever got to the contact
> history.
Adrian,
Excellent point. I don't know why I put active in the contacts table as it
does make more sense to put it in the people table (as some clients have
multiple sites, each with its own contact person).
> Also not sure how you the above result when the query showed:
> WHERE c.active = TRUE AND c.next_contact <= 'today'::date
> Or did the history results come from an undisclosed query?
I don't recall which query I used for the MWE. I'll move the active column
to the new table, as well as those values, and keep working on learning how
to formulate complex, multi-table queries.
Also, moving the active table to peoples, where there is only one row per
person (rather than multiple contact rows per person) removes the need to
find only the most recent row in the many of the one-to-many relationship.
Thanks for the advice,
Rich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: rshepard@appl-ecosys.com
Subject: Re: Refining query statement
In-Reply-To: <alpine.LNX.2.20.1901171559400.18965@salmo.appl-ecosys.com>
References: <alpine.LNX.2.20.1901150738320.5845@salmo.appl-ecosys.com> <9a5976c8-76da-f06d-9840-5dcf8723e38b@gmx.net> <alpine.LNX.2.20.1901170759560.13573@salmo.appl-ecosys.com> <68ed1eaa-7a03-fbaf-26e2-a1979b636174@aklaver.com> <alpine.LNX.2.20.1901171424280.18965@salmo.appl-ecosys.com> <fad7d8c4-0954-97dc-eff6-a8d1942f8dc4@aklaver.com> <alpine.LNX.2.20.1901171559400.18965@salmo.appl-ecosys.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox