Re: Get the last record alone from the select statement. - Mailing list pgsql-novice

From Ron Johnson
Subject Re: Get the last record alone from the select statement.
Date
Msg-id 1059136610.26034.48.camel@haggis
Whole thread Raw
In response to Re: Get the last record alone from the select statement.  ("A.Bhuvaneswaran" <bhuvan@symonds.net>)
List pgsql-novice
On Fri, 2003-07-25 at 04:53, A.Bhuvaneswaran wrote:
> > Hi all,
> >   I have a doubt in limit clause. With limit and offset i can get the
> > first few records from the select statement. Suppose i want to get the
> > last record alone from the select, how can i achieve it.
>
> => select your_fields from your_table where your_condition order by
> oid desc limit 1;

Since oid is way non-standard, a better way may be:
=> select your_fields from your_table where your_condition order by
your_fields desc limit 1;

--
+-----------------------------------------------------------------+
| Ron Johnson, Jr.        Home: ron.l.johnson@cox.net             |
| Jefferson, LA  USA                                              |
|                                                                 |
| "I'm not a vegetarian because I love animals, I'm a vegetarian  |
|  because I hate vegetables!"                                    |
|    unknown                                                      |
+-----------------------------------------------------------------+



pgsql-novice by date:

Previous
From: papapep
Date:
Subject: Re: Questions about Exists-Not exists clause
Next
From: Bruno Wolff III
Date:
Subject: Re: Questions about Exists-Not exists clause