From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Rich Shepard <rshepard(at)appl-ecosys(dot)com> |
Cc: | "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Selecting table row with latest date [RESOLVED] |
Date: | 2021-08-19 21:59:34 |
Message-ID: | CAKFQuwZg6STKM9PDbKX+W-iyDqFzzSaBVBkOY4JOrRJFt1Lgbg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, Aug 19, 2021 at 2:52 PM Rich Shepard <rshepard(at)appl-ecosys(dot)com>
wrote:
> On Thu, 19 Aug 2021, David G. Johnston wrote:
>
> > I thought you said (p.person_nbr, c.contact_date) is already unique?
>
> Yes, that's the PK for the contacts table. I'm still unsure what needs to
> be
> explicitly included in a query. Quite often I leave out a column and
> postgres tells me it needs to be included in order by or group by.
>
>
Well, in this case I suspect you had made a different mistake which caused
the error message (probably the max(c.next_contact)) but instead of solving
the original problem (removing the max(...)) you decided that two wrongs
(adding or extending a group by) would hopefully make a right (which it
did, technically). But while the query works it is definitely not
conceptually correct.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Rich Shepard | 2021-08-19 22:07:37 | Re: Selecting table row with latest date [RESOLVED] |
Previous Message | Rich Shepard | 2021-08-19 21:52:43 | Re: Selecting table row with latest date [RESOLVED] |