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

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: [HACKERS] Re: [SQL] Finding the "most recent" rows
Дата
Msg-id 199904231943.PAA12098@candle.pha.pa.us
обсуждение исходный текст
Список pgsql-hackers
> Chris Bitmead <chris.bitmead@bigfoot.com> writes:
> >>>>>>> select title, summary, time from story t where time = (select
> >>>>>>> max(s.time) from story s GROUP BY s.title);
> >> 
> >>>> Why doesn't replacing "=" with "IN" produce a result? It wouldn't be the
> >>>> desired result, but I thought this was legal.
> >> 
> >> I thought so too (on both counts).  Are you saying it doesn't work?
> >> What happens?  Which version are you using?
> 
> > httpd=> select title, summary, time from story t where time IN (select
> > max(s.time) from story s GROUP BY s.title);
> > ERROR:  parser: Subselect has too many or too few fields.

This is not legal.  If you use GROUP BY, the field must be in the target
list.  In this case, s.title is not in the target list of the subselect.
I realize it can't be in the subselect target list because you can only
have one column in the target list, but that is the case.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] PostgreSQL Webpage -> PGSQL Advocacy
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] Re: light dawns: serious bug in FE/BE protocol handling