How will you delete duplicate records from a table?

Answers were Sorted based on User's Feedback



How will you delete duplicate records from a table?..

Answer / tharanath.n

delete from table a
where rowid >(select min(rowid) from table b
where a.column = b.column);

Is This Answer Correct ?    13 Yes 5 No

How will you delete duplicate records from a table?..

Answer / ajay kumar ande

question is wrong......records-----files,table-----rows
How will you delete duplicate records(rows) from a table?

pgm=sort
sortin dd dsn=-----
sortout dd dsn=-----
sysin dd *
sort fields=(2,3,ch,a)
sum fields=none ------>eliminates duplicate recs

Is This Answer Correct ?    3 Yes 1 No

How will you delete duplicate records from a table?..

Answer / venkat

delete from emp where ecode IN ( select ecode from emp group by ecode having count(*) >1 )

Is This Answer Correct ?    5 Yes 4 No

How will you delete duplicate records from a table?..

Answer / mehdee

Hi. This is a database design problem, because if you
alowe duplicate rows then you must have at least a column
being like squence number.

Is This Answer Correct ?    2 Yes 2 No

How will you delete duplicate records from a table?..

Answer / naresh.s

in DB2
first we need to know duplicate records in database file
like tmpfilep ,for that

select RRN(A) from tmpfilep A where field='fieldvalue'

here field means any fileld containd tmpfilep and
corresponding value.

once we execute the above query we will get relative record
numbers of each row and remember that numbers
now you can delete records based on these numbers

delete from tmpfilep A where rrn(A) in (234,341,642)

here 234,341,642 are sample record numbers

may be i am correct upto my knowledge.......

Is This Answer Correct ?    0 Yes 0 No

How will you delete duplicate records from a table?..

Answer / king

DELETE FROM FILE WHERE FIELD = ALL(SELECT FIELD FROM FILE
GROUP BY FIELD HAVING COUNT(*) > 1)


OR


DELETE FROM FILE WHERE FIELD = ANY(SELECT FIELD FROM FILE
GROUP BY FIELD HAVING COUNT(*) > 1)

Is This Answer Correct ?    1 Yes 7 No

How will you delete duplicate records from a table?..

Answer / s

DELETE FROM TABLE ABC
WHERE COLUMN =
(SELECT COLUMN FROM TABLE ABC
GROUP BY COLUMN
HAVING COUNT(*) > 1);

Is This Answer Correct ?    20 Yes 36 No

Post New Answer

More DB2 Interview Questions

Is Cursor exicutable ?

3 Answers   TetraSoft,


What do you mean by storage group (stogroup)?

0 Answers  


What is the difference between IN subselects and EXISTS subselect?

1 Answers   HCL, PreVator, TCS,


What does db2 stand for?

0 Answers  


If there is no row in Emp table with Ename as Raghava and you run the below queries in SPUFI. 1.select Ename from EMP wher Ename = 'raghava' 2.Select count(*) from EMP where Ename = 'raghava' What is SQLCODE shown up in SPUFI

4 Answers   ADP,






How do you retrieve the first 5 characters of firstname column of db2 table emp?

1 Answers  


I HAVE 500 ROW TO UPDATE I WOULD LIKE TO USE ROLLBACK ALONG WITH COMMIT.WHAT IS THE SYNTAX TO CODE COMMIT AND ROLLBACK FOR EVERY 100 ROWS.AND HOW THE CURSOR ROLLBACK TO THE LAST COMMITTING POINT.

0 Answers   ITC Infotech, Syntel,


What is SPUFI?

4 Answers  


select * from orders where odate between '2010-01-01'and '2010-03-31' How do u fetch this into cursor?

2 Answers  


could you give me an example how, where i code CHECKPOINT and restart...I need and example....thanks..

5 Answers  


Which is faster delete or truncate?

0 Answers  


How is a typical db2 batch pgm executed?

0 Answers  


Categories