pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rich Shepard <rshepard@appl-ecosys.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Refining query statement [DONE]
Date: Fri, 18 Jan 2019 07:56:22 -0800 (PST)
Message-ID: <alpine.LNX.2.20.1901180750230.4540@salmo.appl-ecosys.com> (raw)
In-Reply-To: <alpine.LNX.2.20.1901150738320.5845@salmo.appl-ecosys.com>
References: <alpine.LNX.2.20.1901150738320.5845@salmo.appl-ecosys.com>

On Tue, 15 Jan 2019, Rich Shepard wrote:

> Working with my sales/client management system using psql I have a select
> statement to identify contacts to be made. This statement works:

With much patient advice from Adrian, David, Thomas, and Ron I fixed the
schema and the query statement. To close this thread I post the query that
meets my goal and provide the information I need. Formatting this as a
report will be the job of SQLAlchemy and wxPython.

/* This query selects all contact information and notes from those people
    whose next_contact date is today or earlier; only active persons. */

/* Specify columns */
SELECT p.lname, p.fname, p.direct_phone, p.active, o.org_name,
        a.act_date, a.act_type, a.notes, a.next_contact, a.comment
/* Specify tables. */ 
FROM People AS p
      JOIN Organizations AS o ON o.org_id = p.org_id
      JOIN Activities AS a ON a.person_id = p.person_id
/* Specify rows */ 
WHERE p.active = TRUE AND
       a.next_contact <= 'today'::date
GROUP BY o.org_name, p.person_id, a.person_id, a.act_date, a.act_type,
       a.next_contact
ORDER BY p.person_id, a.next_contact DESC;

I really appreciate your help.

Best regards,

Rich




Message-ID: <alpine.LNX.2.20.1901180750230.4540@salmo.appl-ecosys.com>
Permalink:  ../alpine.LNX.2.20.1901180750230.4540@salmo.appl-ecosys.com/
Also on:    postgresql.org/message-id/alpine.LNX.2.20.1901180750230.4540@salmo.appl-ecosys.com

 · 

reply

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 [DONE]
  In-Reply-To: <alpine.LNX.2.20.1901180750230.4540@salmo.appl-ecosys.com>
  References: <alpine.LNX.2.20.1901150738320.5845@salmo.appl-ecosys.com> <alpine.LNX.2.20.1901180750230.4540@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