| From: | Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net> | 
|---|---|
| To: | PgSQL Novice ML <pgsql-novice(at)postgresql(dot)org> | 
| Subject: | Re: Get the last record alone from the select statement. | 
| Date: | 2003-07-25 12:36:51 | 
| Message-ID: | 1059136610.26034.48.camel@haggis | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | 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(dot)l(dot)johnson(at)cox(dot)net             |
| Jefferson, LA  USA                                              |
|                                                                 |
| "I'm not a vegetarian because I love animals, I'm a vegetarian  |
|  because I hate vegetables!"                                    |
|    unknown                                                      |
+-----------------------------------------------------------------+
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bruno Wolff III | 2003-07-25 14:20:29 | Re: Questions about Exists-Not exists clause | 
| Previous Message | papapep | 2003-07-25 10:38:41 | Re: Questions about Exists-Not exists clause |