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

What is a precompiler?

2 Answers  


Can i insert bulk records into a db2 table using qmf of spufi only............!!!

2 Answers  


What is a synonym ?

2 Answers  


Can we update view in db2?

0 Answers  


What is table space in db2?

0 Answers  


i know the stpes 2 create an executable CICS/DB2 cobol code. 1. DB2 Precompiler converts the SQL Statements into COBOL API statements and creates another member with Acess plans. CodeA results in CodeB (code with API calls) & CodeC ( Access Plans ) 2.Code B is compiled/linked 2 create an exceutable.(codeE) 3.Now CodeC is binded to the database on which CodeE will be run. Can somebody provide me the sample JCLs for precompile/compile/link/bind.

0 Answers  


How to get the ddl of a table in db2?

0 Answers  


can all users have the privilage to use the sql statement select * (dml)?

0 Answers   IBM,


how do you resolve -805?

3 Answers   HCL,


If a table has a column "dept" (declared to have nulls) and there are 10 rows in the table of which 3 have a null value in the dept column, what will select count(*) and select count(distinct dept) return?

6 Answers  


what is the Foreign key? explain?

2 Answers  


What is the difference between using bind () and rebind () methods of naming class?

0 Answers  


Categories