From: Bruce Momjian <maillist@candle.pha.pa.us>
To: tgl@sss.pgh.pa.us
Cc: chris.bitmead@bigfoot.com
Cc: pgsql-sql@postgreSQL.org
Cc: pgsql-hackers@postgreSQL.org
Subject: Re: [HACKERS] Re: [SQL] Finding the "most recent" rows
Date: Fri, 23 Apr 1999 15:43:11 -0400 (EDT)
Message-ID: <199904231943.PAA12098@candle.pha.pa.us> (raw)
In-Reply-To: <21809.924883569@sss.pgh.pa.us>
> 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, Pennsylvania 19026
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: maillist@candle.pha.pa.us, tgl@sss.pgh.pa.us, chris.bitmead@bigfoot.com, pgsql-hackers@postgreSQL.org
Subject: Re: [HACKERS] Re: [SQL] Finding the "most recent" rows
In-Reply-To: <199904231943.PAA12098@candle.pha.pa.us>
References: <21809.924883569@sss.pgh.pa.us> <199904231943.PAA12098@candle.pha.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox