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
What is scope and visibility in PL/SQL?
List out the acid properties and explain?
Is primary key is clustered index?
What is the use of primary key?
What is natural join in sql?
Are sql connections encrypted?
Which table is left in join?
What is sqlerrd?
What is Difference Between Unique and Primary Key Constraints?
Can you rollback after commit?
what are the 'mysql' command line options? : Sql dba
How do you rank data in sql?
How can you fetch common records from two tables?
Define commit?
What are the types of variable use in pl sql?