Re: [SQL] Finding the "most recent" rows

Поиск
Список
Период
Сортировка
От Chris Bitmead
Тема Re: [SQL] Finding the "most recent" rows
Дата
Msg-id 371FDB49.7E7FBA35@bigfoot.com
обсуждение исходный текст
Ответ на Re: [SQL] Finding the "most recent" rows  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [SQL] Finding the "most recent" rows
Список pgsql-sql
Tom Lane wrote:
> 
> Chris Bitmead <chris.bitmead@bigfoot.com> writes:
> > Clever. But why doesn't this work....
> 
> > select title, summary, time from story t where time = (select
> > max(s.time) from story s GROUP BY s.title);
> > ERROR:  parser: Subselect has too many or too few fields.
> 
> A subselect used in an expression has to return exactly one value;
> yours will return as many tuples as there are distinct titles.

Why doesn't replacing "=" with "IN" produce a result? It wouldn't be the
desired result, but I thought this was legal.


В списке pgsql-sql по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [SQL] Finding the "most recent" rows
Следующее
От: Chris Bitmead
Дата:
Сообщение: Re: [SQL] SELECT TOP _x_ ??