Re: Refining query statement [DONE]
От | Rich Shepard |
---|---|
Тема | Re: Refining query statement [DONE] |
Дата | |
Msg-id | alpine.LNX.2.20.1901180750230.4540@salmo.appl-ecosys.com обсуждение исходный текст |
Ответ на | Refining query statement (Rich Shepard <rshepard@appl-ecosys.com>) |
Список | pgsql-general |
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
В списке pgsql-general по дате отправления: