Re: [GENERAL] retrieving last 3 rows - Mailing list pgsql-general

From Aaron J. Seigo
Subject Re: [GENERAL] retrieving last 3 rows
Date
Msg-id 99102511270801.00882@stilborne
Whole thread Raw
In response to retrieving last 3 rows  (soundar rajan <psrajan@yahoo.com>)
List pgsql-general
hi...

> 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;

an easy way is to do this:

select * from T-name order by oid desc, PK limit 3;

this will not return them in PK order, but by order of writing... if PK is
incremented every record, they will appear in reverse order...

hope this helps...

--
Aaron J. Seigo
Sys Admin

pgsql-general by date:

Previous
From: "E.E. Mellor"
Date:
Subject: Re: [INTERFACES] Re: LIKE clause
Next
From: Courtney Thomas
Date:
Subject: HELP: {compiling 6.5.2 on FreeBSD3.3} <-error