write a query to delete similar records in same table

Answer Posted / santosh kumar

simple answer for deleting duplicate record from a table.....
table:---
create table t1 (id number(5),name varchar2(20));

then:----
insert into t1 values(10,'a');
insert into t1 values(10,'a');
insert into t1 values(20,'b');
insert into t1 values(20,'b');
---after insertion it'll like this----
id name
10 a
10 a
20 b
20 b

-------------------------------------------------------------
delete from t1
where rowid not in (select min(rowid) from t1 group by name);

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of double ampersand (&&) in sql queries? Give an example

596


Which language is used in sql?

510


Explain exception handling in pl/sql?

520


Which is faster subquery or join?

646


Is sql injection illegal?

584






What is the difference between sql and isql*plus?

505


What is difference between function and trigger?

534


Explain polymorphism in pl/sql.

631


What is a scalar value in sql?

570


How do you pronounce sql?

538


What is the use of stored procedures?

506


Why is pl sql needed?

498


what are the differences between require and include, include_once and require_once? : Sql dba

517


How does a trigger work?

526


what is bcp? When is it used?

568