How do you retrieve the last N records from a table?

Answer Posted / kiran penujuri

This Will give you last 10 records from a table

SELECT EMPNAME,SALARY
FROM
(SELECT EMPNAME,
SALARY,
RANK() OVER(ORDER BY SALARY) SAL_RANK
FROM EMP)
WHERE SAL_RANK < = 10

Is This Answer Correct ?    1 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What packages are available to pl/sql developers?

809


The in operator may be used if you know the exact value you want to return for at least one of the columns.

723


Is sql sequential or random?

770


Why query optimization is needed?

679


How do I tune a sql query?

723






what is sub-query? : Transact sql

836


What is the use of count (*) in sql?

750


What is materialized view. What are different methods of refresh?

1065


Are stored procedures faster than queries?

694


Explain normalization and what are the advantages of it?

691


Is ms sql traffic encrypted?

680


what is the difference between delete and truncate statement in sql? : Sql dba

758


Is sql easier than java?

734


Is it possible to include an insert statement on the same table to which the trigger is assigned?

731


What is trigger explain it?

737