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

From Tom Lane
Subject Re: Getting 'n-1'th record.
Date
Msg-id 29402.998403697@sss.pgh.pa.us
Whole thread Raw
In response to Getting 'n-1'th record.  (Bhuvan A <bhuvansql@yahoo.com>)
List pgsql-sql
Bhuvan A <bhuvansql@yahoo.com> writes:
> I need ONLY the 'n-1'th record.

See the 'LIMIT' and 'OFFSET' clauses in SELECT.  Note the caveat that
you'd better ORDER the rows to be sure you know which is the n-1'th.
Having done an ORDER BY, you could simplify your life by reversing
the ordering and choosing the second row (OFFSET 1 LIMIT 1).
        regards, tom lane


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: database location question
Next
From: "Jeff Eckermann"
Date:
Subject: Re: split/explode functions