Can't it be like this
Select * from table name where rownum>((select count(*) from table name)-n);
where n is the number of records we want from the end.
Actually i haven't used it till now. please reply me if it worked or not.
Actually you can make it faster when you know different things:
* There are constant flow of records every day and you have a timestamp or datetime column with the time that record was added.
select tmp.ID, tmp.name, tmp.error_message
from (select ID, name, error_message
where created_time >= trunc(sysdate)
order by created_time desc) tmp
where rownum <= 10;
* You have autoincremental ID, primary key, and no deletes are made in that table
SELECT ID, name
WHERE ID >= (SELECT LAST_NUMBER - 10 FROM ALL_SEQUENCES WHERE SEQUENCE_NAME = 'SEQUENCE1')