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 subquery? : Sql dba
Can you sum a count in sql?
Are ddl triggers fired for ddl statements within a pl/sql code executed using the dbms.sql package?
Does normalization improve performance?
Is sql similar to python?
How many types of tables are there?
What is the difference between union and union all command?
How to process query result in pl/sql?
What is varray in pl sql?
What is left join in sql?
what is clause? : Sql dba
What is the difference between the conventional and direct path loads? : aql loader
Is sql low level language?
How many functions are there in sql?
How to load data with sql*loader?