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

From: Chris Bitmead <chris(dot)bitmead(at)bigfoot(dot)com>
To: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgreSQL(dot)org>
Subject: Re: [SQL] Finding the "most recent" rows
Date: 1999-04-23 02:30:33
Message-ID: 371FDB49.7E7FBA35@bigfoot.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Tom Lane wrote:
>
> Chris Bitmead <chris(dot)bitmead(at)bigfoot(dot)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.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Chris Bitmead 1999-04-23 02:34:34 Re: [SQL] SELECT TOP _x_ ??
Previous Message Chris Bitmead 1999-04-23 02:00:03 Re: [SQL] Finding the "most recent" rows