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 the different types of functions in sql?
what is the order of pre-defined exceptions.
What are different joins used in sql?
Explain character-manipulation functions?
Why partition by is used in sql?
using comand prompt how can import table data and table space with example
How do I copy a table in sql?
What are the advantages of the packages
Does truncate free space?
List the ways to get the count of records in a table?
What are the types of views in sql?
What is record data type?
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)