Re: [SQL] Most recent row

Поиск
Список
Период
Сортировка
Искать
От
hubert depesz lubaczewski
Тема
Re: [SQL] Most recent row
Дата
в 12:35:05
Msg-id
20170505093505.GA5611@depesz.com
Ответ на
[SQL] Most recent row (Gary Stainburn)
Список
Дерево обсуждения
[SQL] Most recent row Gary Stainburn <gary.stainburn@ringways.co.uk>
Re: [SQL] Most recent row Karsten Hilbert <Karsten.Hilbert@gmx.net>
Re: [SQL] Most recent row Gary Stainburn <gary.stainburn@ringways.co.uk>
Re: [SQL] Most recent row hubert depesz lubaczewski <depesz@depesz.com>
Re: [SQL] Most recent row Gary Stainburn <gary.stainburn@ringways.co.uk>
Re: [SQL] Most recent row hubert depesz lubaczewski <depesz@depesz.com>
Re: [SQL] Most recent row Gary Stainburn <gary.stainburn@ringways.co.uk>
Re: [SQL] Most recent row hubert depesz lubaczewski <depesz@depesz.com>
Re: [SQL] Most recent row Gary Stainburn <gary.stainburn@ringways.co.uk>
Re: [SQL] Most recent row Bob Edwards <bob@cs.anu.edu.au>
Re: [SQL] Most recent row vinny <vinny@xs4all.nl>
Re: [SQL] Most recent row "David G. Johnston" <david.g.johnston@gmail.com>
Re: [SQL] Most recent row Adrian Klaver <adrian.klaver@aklaver.com>
Re: [SQL] Most recent row Michael Moore <michaeljmoore@gmail.com>
Re: [SQL] Most recent row Michael Moore <michaeljmoore@gmail.com>
Re: [SQL] Most recent row Michael Moore <michaeljmoore@gmail.com>
Re: [SQL] Most recent row Thomas Kellerer <spam_eater@gmx.net>
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
>   ..
> ;

How many rows are in people? How many in assessments? Do you really want
data on all people? Or just some?

Best regards,

depesz



В списке pgsql-sql по дате отправления
От: Gary Stainburn
Дата:
Сообщение: Re: [SQL] Most recent row
От: Gary Stainburn
Дата:
Сообщение: Re: [SQL] Most recent row
FAQ