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
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 |
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 |
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 |
What are stored procedures in mysql?
What is an index in sql with example?
What is oracle sql developer?
Explain how exception handling is done in advance pl/sql?
how to load data with out header and footer records in a database using sql*loader? pls tell me the answer urgently
How to rename a column in the output of sql query?
What are the operators used in select statements?
How delete all data from all tables in sql?
How can a pl sql block be executed?
Can a table contain multiple foreign key’s?
What are user defined functions?
What is dba in sql? : SQL DBA