Can this be done in one query?

From: Randall Perry <rgp(at)systame(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Can this be done in one query?
Date: 2002-05-07 21:34:27
Message-ID: B8FDC0A3.145ED%rgp@systame.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

With the following:

select max(date) from log order by date_time desc limit 12;

The limit clause has no effect on the results; it'll get the latest date
from the entire record set rather than from the last 12 records.

It works if I do this:
create temp table as select date from log order by dat_time desc limit
12;

select max(date) from temp;

So, is there a way to do this in one query without creating a temp table?

--
Randy Perry
sysTame
Mac Consulting/Sales

phn 772.589.6449
mobile email help(at)systame(dot)com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tino Wildenhain 2002-05-07 22:14:55 restoring databases with intensive foreign key use fails
Previous Message lloyd 2002-05-07 21:21:10 JDBC - escaping quotes?