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 are pl sql data types?
What is sorting in sql?
How to order siblings in oracle hierarchy queries?
Is a view faster than a stored procedure?
What is sql character function?
What is the function that is used to transfer a pl/sql table log to a database table?
what are the different index configurations a table can have? : Sql dba
Can you do multiple joins in sql?
how can we encrypt and decrypt a data present in a mysql table using mysql? : Sql dba
Describe different types of general function used in sql?
what is a field in a database ? : Sql dba
What is the non-clustered index in sql?
Can we debug stored procedure?
What are the possible values for the boolean data field?
What is the unique index?