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

What are stored procedures in mysql?

0 Answers  


What is an index in sql with example?

0 Answers  


What is oracle sql developer?

0 Answers  


Explain how exception handling is done in advance pl/sql?

0 Answers  


how to load data with out header and footer records in a database using sql*loader? pls tell me the answer urgently

1 Answers   Oracle, Wipro,






How to rename a column in the output of sql query?

0 Answers  


What are the operators used in select statements?

0 Answers  


How delete all data from all tables in sql?

0 Answers  


How can a pl sql block be executed?

0 Answers  


Can a table contain multiple foreign key’s?

0 Answers  


What are user defined functions?

0 Answers  


What is dba in sql? : SQL DBA

0 Answers  


Categories