retrieving last 3 rows

From: soundar rajan <psrajan(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: retrieving last 3 rows
Date: 1999-10-25 14:22:12
Message-ID: 19991025142212.7394.rocketmail@web2105.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all,

I need to retrieve the last n rows from a table. In
Oracle, I write it as

select * from T_name where rowid > (select max(rowid)
from T_name) order by PK;

In pg, I wrote the same with needed casting as,

select * from T_name where int8(oid) > (select
max(int8(oid)) from T_name) order by PK;

The problem is, the oid returned is not in an order,
it's not consecutive, in which case, the no. of rows
to be retrieved is not predictable.

the sample oid in my table is 19682,19744....

Can any one help me in getting the same.

Thanks in advance.

__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Byrnes 1999-10-25 16:03:55 [INTERFACES] Re: LIKE clause
Previous Message Peter Eisentraut 1999-10-25 13:16:48 Re: [GENERAL] Import data from a file