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's the difference between a primary key and a unique key? : Sql dba
Explain how to use transactions efficiently : transact sql
What is denormalization in a database?
how would you enter characters as hex numbers? : Sql dba
How do I use google cloud in sql?
What is the usage of when clause in trigger?
what are the different tables present in mysql? : Sql dba
What does partition by mean in sql?
How can you select unique records from a table?
What is t-sql? : Transact sql
What are the different types of dbms?
What is full join?
What are data types in pl sql?
What are the two types of cursors in pl sql?
What is primary key sql?