Re: Refining query statement

From: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Refining query statement
Date: 2019-01-18 00:04:45
Message-ID: alpine.LNX.2.20.1901171559400.18965@salmo.appl-ecosys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2019-01-18 00:07:19 Re: Refining query statement
Previous Message Adrian Klaver 2019-01-17 23:58:07 Re: Refining query statement