pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Rich Shepard <rshepard@appl-ecosys.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Refining query statement
Date: Tue, 15 Jan 2019 07:54:57 -0800
Message-ID: <bf7e79c6-0fa4-f730-dfdc-175576db8d66@aklaver.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 1/15/19 7:39 AM, 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:
> 
> select (C.contact_id, C.lname, C.fname, C.direct_phone, O.org_name, 
> A.next_contact)
> from Contacts as C, Organizations as O, Activities as A
> where C.org_id = O.org_id and C.contact_id = A.contact_id and
>        A.next_contact <= 'today' and A.next_contact > '2018-12-31' and
>        A.next_contact is not null;
> 
> but would benefit from tweaking. When I have had multiple contacts with
> someone I want only the most recent one displayed, not all, and they should
> be no more ancient than a defined period (e.g., a month).
> 
>    I want to learn how to make this query cleaner and more flexible. When I
> write the UI for this I want to be able to specify a data range in addition
> to a fixed 'today'. Pointers on what to read will be very helpful.

For the above I could see using a datepicker widget that allows for 
multidate select. The specifics would depend on the software you are 
using to write the UI.

> 
> TIA,
> 
> Rich
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com




view thread (32+ messages)  latest in thread

Message-ID: <bf7e79c6-0fa4-f730-dfdc-175576db8d66@aklaver.com>
Permalink:  ../bf7e79c6-0fa4-f730-dfdc-175576db8d66@aklaver.com/
Also on:    postgresql.org/message-id/bf7e79c6-0fa4-f730-dfdc-175576db8d66@aklaver.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: adrian.klaver@aklaver.com, rshepard@appl-ecosys.com
  Subject: Re: Refining query statement
  In-Reply-To: <bf7e79c6-0fa4-f730-dfdc-175576db8d66@aklaver.com>
  References: <alpine.LNX.2.20.1901150738320.5845@salmo.appl-ecosys.com> <bf7e79c6-0fa4-f730-dfdc-175576db8d66@aklaver.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