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 is the advantage of index in sql?
What is a dirty read sql?
What is the difference between the Primary and Foreign key?
What is sql and how does it work?
Define commit, rollback and savepoint?
What is INSTEAD OF trigger ?
How can u find column name from a table which have max value in a row.( not max value)
How do I audit the sql sent to the server?
how to calcuate the second highest salary of he employee
diff b/w function and procedure?
What is sql resultset?
What is a Procedure ?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)