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-22 23:57:32
Message-ID: 371FB76C.65A146D7@bigfoot.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Tom Lane wrote:

> SELECT DISTINCT ON place * FROM table ORDER BY place, time DESC;

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.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Chris Bitmead 1999-04-23 00:18:33 Re: [SQL] SELECT TOP X -- part 2 -- parse error?
Previous Message Paul E Stephens 1999-04-22 23:39:18 Replacing PREPARE