how to delete duplicate rows from a specified table(only
single table)
how do you know which join is need to be used

Answers were Sorted based on User's Feedback



how to delete duplicate rows from a specified table(only single table) how do you know which join..

Answer / mkumar.it

delete <table_name> where rowid not in (select min(rowid)
from <table_name> group by <dup_rec_col>)

max(rowid) can also be used provided you have to retain the
latest value other wise min(rowid) is fine.

Is This Answer Correct ?    8 Yes 0 No

how to delete duplicate rows from a specified table(only single table) how do you know which join..

Answer / dinesh mohan upadhyay

delete from emp
where rowid>any(select min(rowid) from emp a where
a.col1=col1)

Is This Answer Correct ?    15 Yes 8 No

how to delete duplicate rows from a specified table(only single table) how do you know which join..

Answer / samir kumar sahoo.

DELETE FROM tablename A WHERE ROWID>(SELECT MIN(ROWID) FROM
tablename B WHERE A.key_values=B.key_values);

Is This Answer Correct ?    6 Yes 2 No

how to delete duplicate rows from a specified table(only single table) how do you know which join..

Answer / lakshya

SELECT * FROM table_name
WHERE ROWID NOT IN (SELECT MIN(ROWID) FROM table_name GROUP
BY table_columns);

Is This Answer Correct ?    9 Yes 8 No

how to delete duplicate rows from a specified table(only single table) how do you know which join..

Answer / raghavendraprasad

delete from table_name where rowid not in (select max
(rowid) from table group by duplicate_values_field_name);

Is This Answer Correct ?    2 Yes 1 No

how to delete duplicate rows from a specified table(only single table) how do you know which join..

Answer / jas

delete from table_name where rowid > (select min(rowid)
from table_name where a.col_name=b.col_name)

create new_table as select distinct * from table_name;
drop table_name;
create table_name as select * from new_table;
drop new_table;

delete from table_name where rowid not in (select max
(rowid) from table_name where a.col_name=b.col_name)

Is This Answer Correct ?    1 Yes 0 No

how to delete duplicate rows from a specified table(only single table) how do you know which join..

Answer / venkateswararao

delete from emp p where rowid<(select max(rowid) from emps where p.ename=s.ename)

Is This Answer Correct ?    1 Yes 0 No

how to delete duplicate rows from a specified table(only single table) how do you know which join..

Answer / kishor solanki @ 9904762204

CREATE TABLE new_table as SELECT * FROM test GROUP BY url;
DROP TABLE test;
RENAME TABLE new_table TO test;

Is This Answer Correct ?    1 Yes 0 No

how to delete duplicate rows from a specified table(only single table) how do you know which join..

Answer / yankee

If you wish to remove duplicate values, then use the
DISTINCT parameter.
Consider there is a table:emp, with deptno. as one of its
coloumn. This coloumn has repeated values. Then you should
use the following query to remove the duplicate values:
SELECT DISTINCT deptno FROM emp;

Is This Answer Correct ?    2 Yes 2 No

how to delete duplicate rows from a specified table(only single table) how do you know which join..

Answer / arif jameel

First add an Identity Column in table

Alter table <tblname>
Add < New_columnID > int identity(1,1)

Delete from <tblname> where < New_columnID> in
(select max(New_columnID)from <tblname>
Group by <tbl_columnname>
having count (<tbl_columnname>)>1)

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More SQL PLSQL Interview Questions

Wat is SGA ?

3 Answers   ABB,


Question: Below is the table city gender name delhi male a delhi female b mumbai male c mumbai female d delhi male e I want the o/p as follows: male female delhi 2 1 mumbai 1 1 Please help me in writing the query that can yield the o/p mentioned above?

2 Answers  


What is the use of cursor ? how cursor allocate context area for executing the sql statement?

4 Answers   HCL,


What is rename command in sql?

0 Answers  


How do I use google cloud in sql?

0 Answers  






write sub query for eliminating duplicate rows using analytical function?

3 Answers   Metric Stream,


Where are my tempfiles, I don't see them in v$datafile or dba_data_file?

0 Answers  


What are the most important ddl statements in sql?

0 Answers  


declare v_count number(8,3); v_sal scott.emp.sal%type := '&P_sal'; cursor cur_name is select sal from scott.emp where sal between (v_sal-100) and (v_sal +1000); begin v_count :=nvl(sql%rowcount ,0); if v_count = 0 then dbms_output.put_line('no records are fetch in the given sal range'); else dbms_output.put_line('There is/are '||to_char(v_count)|| ' salaries are selected in the given range '); end if; end; in the above programm .....for any sal range ....always it shows the following message.. no records are fetch in the given sal range please find the mistake and share with me...with thansk and regards..sarao....

3 Answers   Satyam,


What is multiple columns?

0 Answers  


Is sql open source?

0 Answers  


Why do you partition data?

0 Answers  


Categories