Re: last 25 records from a dataset

From: denis(at)coralindia(dot)com
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: last 25 records from a dataset
Date: 2002-07-10 06:16:42
Message-ID: 006001c227d9$5d69da80$0232a8c0@coralindia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


Want to retrieve last 25 (recently) inserted records.. use

Order by OID DESC limit 25

Denis

----- Original Message -----
From: "Brian Scandale" <Brrrian(at)Excite(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Sent: Sunday, July 07, 2002 5:18 AM
Subject: [NOVICE] last 25 records from a dataset

> I am looking for the correct way to retrieve the last 25 records from a
dataset without having to first retrieve the entire dataset to pull out the
last 25.
>
> The potential dataset can be very large... 10,000 records that match the
query... yet I only can use the most recent 25.
>
> my first idea is:
>
> SELECT *
> FROM table
> WHERE thisField=thatValue etc...
> ORDER BY table_id DESC
> LIMIT 25
>
> But I'm not confident in this and looking for a yeah or nay from a guru or
two or three.
>
> Thanks,
> Brian
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Jürgen Mischke 2002-07-10 07:55:32 Re: update problem?
Previous Message denis 2002-07-10 06:14:12 Re: Importing dbf files to postgresql