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 via email to