Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: how to get the last record
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
![]() |
![]() |