how will you find out the last three records in a table
with n no of records and delete them

Answers were Sorted based on User's Feedback



how will you find out the last three records in a table with n no of records and delete them..

Answer / aswin

This query cost the performance :
delete from emp where empno in (select empno from (select
empno from emp order by rowid desc) where rownum <= 3)

Is This Answer Correct ?    9 Yes 0 No

how will you find out the last three records in a table with n no of records and delete them..

Answer / ajit

delete from emp
where empno in
(select empno
from emp
minus
select empno
from emp
where rownum <= ( select count(*) - 3
from emp
))

Is This Answer Correct ?    1 Yes 0 No

how will you find out the last three records in a table with n no of records and delete them..

Answer / sudipta santra

delete from
(select * from tab1
minus
select * from tab1 where rownum<n-2 order by rowid)

Is This Answer Correct ?    0 Yes 3 No

Post New Answer

More SQL PLSQL Interview Questions

write a query to delete similar records in different tables with same structure

4 Answers  


What is RAC in oracle?

7 Answers   MCN Solutions,


Is nosql relational?

0 Answers  


How do I remove all records from a table?

0 Answers  


Which is better varchar or nvarchar?

0 Answers  






what is unique key constraint? : Sql dba

0 Answers  


What is a sql statement?

0 Answers  


What are the steps you take to tune(performance tuning) the code in plsql?

4 Answers   Cap Gemini, Infosys, TCS,


What is the purpose of design view?

0 Answers  


Is sql dba a good career? : SQL DBA

0 Answers  


What operating systems are supported by oracle sql developer?

0 Answers  


What is pl sql variable?

0 Answers  


Categories