Re: Getting 'n-1'th record. - Mailing list pgsql-sql

From omid omoomi
Subject Re: Getting 'n-1'th record.
Date
Msg-id F151GQvnbEG10Gai4om0000bf5c@hotmail.com
Whole thread Raw
In response to Getting 'n-1'th record.  (Bhuvan A <bhuvansql@yahoo.com>)
List pgsql-sql
Hi,
It is a not a clean job but how about having a view like this :

create view foo_view as select * from yourtable order by oid desc limit 2 ;

and then making your select like this:
select * from foo_view order by oid limit 1;

hope that helps
Omid

>From: Bhuvan A <bhuvansql@yahoo.com>
>To: pgsql-sql@postgresql.org
>Subject: [SQL] Getting 'n-1'th record.
>Date: Tue, 21 Aug 2001 13:11:33 +0530 (IST)
>
>
>hi all,
>
>consider below..
>
>An sql query results with 'n' records. OK.
>I need ONLY the 'n-1'th record.
>
>
>HOW CAN I GET THIS?
>
>Thankx in advance!
>
>      
>======================================================================
>      Q:    What's the difference between the 1950's and the 1980's?
>      A:    In the 80's, a man walks into a drugstore and states loudly, "I'd
>         like some condoms," and then, leaning over the counter, whispers,
>                   "and some cigarettes."
>
>      
>======================================================================
>
>Regards,
>Bhuvaneswar.
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 4: Don't 'kill -9' the postmaster


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp



pgsql-sql by date:

Previous
From: Bhuvan A
Date:
Subject: Getting 'n-1'th record.
Next
From: darcy@druid.net (D'Arcy J.M. Cain)
Date:
Subject: Re: Primary vs Unique Index