Re: Refining query statement - Mailing list pgsql-general

From Rich Shepard
Subject Re: Refining query statement
Date
Msg-id alpine.LNX.2.20.1901171559400.18965@salmo.appl-ecosys.com
Whole thread Raw
In response to Re: Refining query statement  (Adrian Klaver <adrian.klaver@aklaver.com>)
List 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



pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Refining query statement
Next
From: "David G. Johnston"
Date:
Subject: Re: Refining query statement