What is the SQL query to select, delete and get count of
duplicate rows in DB2?

Answers were Sorted based on User's Feedback



What is the SQL query to select, delete and get count of duplicate rows in DB2?..

Answer / igor kramov

DELETE FROM (
SELECT ROWNUMBER() OVER (PARTITION BY c1, c2 ORDER BY c3
DESC) AS rnum FROM t1)
WHERE rnum > 1 ;

the same is for Select\Count

Is This Answer Correct ?    6 Yes 0 No

What is the SQL query to select, delete and get count of duplicate rows in DB2?..

Answer / hkhatri27

SELECT Columns
FROM Table
GROUP BY Columns
HAVING COUNT(*) > 1;

~ Himanshu

Is This Answer Correct ?    2 Yes 2 No

Post New Answer

More DB2 Interview Questions

What is performance tuning db2?

0 Answers  


What is the error code -803 ?

3 Answers  


Suppose we are doing transaction in a table and abend happened in between. Suppose i have completed the transaction upto X rows and I want to start the transaction again where the abend happened. I don't want to do the transaction from the first record. Then what i have to do.

9 Answers   Cap Gemini,


Which command is used to remove all rows from a table?

0 Answers  


What is the use of reorg in db2?

0 Answers  






What is a db2 collection?

0 Answers  


What is package in db2 mainframe?

0 Answers  


Normalization in DB2 – first normal form, second normal form

4 Answers   Virtusa,


When reorg is used?

0 Answers  


What is runstats and reorg in db2?

0 Answers  


What is the SQL Communications Area and what are some of its key fields?

1 Answers  


What is meant by a unit of recovery?

1 Answers  


Categories