Re: Refining query statement - Mailing list pgsql-general

From David G. Johnston
Subject Re: Refining query statement
Date
Msg-id CAKFQuwZFgogSc1Td0hXz7Jtzn3YvFisDEnPL6+3NLO1O7hsnkA@mail.gmail.com
Whole thread Raw
In response to Re: Refining query statement  (Rich Shepard <rshepard@appl-ecosys.com>)
Responses Re: Refining query statement  (Rich Shepard <rshepard@appl-ecosys.com>)
List pgsql-general
On Thu, Jan 17, 2019 at 9:14 AM Rich Shepard <rshepard@appl-ecosys.com> wrote:
> ORDER BY c.contact_id, a.next_contact DESC;

> The WHERE clause needs to exclude a contact_id where the most current row in
> Activities has NULL for the next_contact column.

Why is next_contact allowed to be null?

Your concept of "most current row" is strictly based upon next_contact
so if next_contact is null it is impossible to know whether it is the
most current row (consider that two activities could be missing the
next_contact date - which of those is the most current?)

David J.


pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Refining query statement
Next
From: Adrian Klaver
Date:
Subject: Re: Refining query statement