Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: how to get the last record

Re: how to get the last record

From: <davide_at_yahoo.com>
Date: 5 Nov 2001 13:42:01 GMT
Message-ID: <9s64v9$10s74j$4@ID-18487.news.dfncis.de>


Sergio Cotti <sergiof31_at_hotmail.com> wrote:
> I have a table as a result of a query and i want to get only the
> last record of this table. What can i do?

Since you ask for a "last" record, I guess you have a way to distinguish it from the others, it's a wild guess but I think you have a Primary Key or other sort of counter that is used to keep your table in a certain order. Then you have to do:

select * from <mytable> where rownum = 1 order by <primarykey> desc

This way the table is ordere upside-down (from the "last" to the "first") and the "rownum=1" clause is used to get just the first record.

hth

Davide Received on Mon Nov 05 2001 - 07:42:01 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US