| From: | Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net> |
|---|---|
| To: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: Most recent row |
| Date: | 2017-05-05 08:32:21 |
| Message-ID: | 20170505083220.wxdqm3bpwfo2dgre@hermes.hilbert.loc |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
On Fri, May 05, 2017 at 09:25:04AM +0100, Gary Stainburn wrote:
> This question has been asked a few times, and Google returns a few different
> answers, but I am interested people's opinions and suggestions for the *best*
> wat to retrieve the most recent row from a table.
>
> My case is:
>
> create table people (
> p_id serial primary key,
> ......
> );
>
> create table assessments (
> p_id int4 not null references people(p_id),
> as_timestamp timestamp not null,
> ......
> );
>
> select p.*, (most recent) a.*
> from people p, assessments a
> ..
> ;
You will need to provide a definition for *exactly* what
"most recent" means in this context.
Karsten
--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
| From | Date | Subject | |
|---|---|---|---|
| Next Message | vinny | 2017-05-05 08:50:36 | Re: Most recent row |
| Previous Message | Gary Stainburn | 2017-05-05 08:25:04 | Most recent row |