how to retrieve last tree records from table?
select *from emp where rownum > (select count(*)-3 from
emp);
i am using this query to get last three records from table
but its not giving any output, so please tell me what is the
error in this query.

Answer Posted / ashwin

if emp table is having 10 records then
1)for first 6 write

select ename,sal from(select ename,sal from emp order by sal
desc) where rownum <7;

2)for last 3 write

select ename,sal from(select ename,sal from emp order by sal
desc) where rownum >7;

Is This Answer Correct ?    2 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is scope and visibility in PL/SQL?

770


List out the acid properties and explain?

711


Is primary key is clustered index?

724


What is the use of primary key?

731


What is natural join in sql?

710






Are sql connections encrypted?

748


Which table is left in join?

693


What is sqlerrd?

701


What is Difference Between Unique and Primary Key Constraints?

827


Can you rollback after commit?

718


what are the 'mysql' command line options? : Sql dba

744


How do you rank data in sql?

680


How can you fetch common records from two tables?

774


Define commit?

752


What are the types of variable use in pl sql?

745