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

List down the types of triggers in the db2 database?

1 Answers  


What is meant by index cardinality?

2 Answers  


What is a collection?

3 Answers  


Explain about cursor stability?

1 Answers  


Explain correlated sub-queries.

1 Answers  


What is the difference between nvl and coalesce?

1 Answers  


What is the result of open cursor statement?

1 Answers  


Define sqlca.

1 Answers  


What are foreign keys in db2?

1 Answers  


How do I start db2 in windows?

1 Answers  


What error I will get if my select query gives multiple row while executing a Cobol-DB2 program.How can I solve it without using a cursor.

4 Answers   Cap Gemini, Verizon,


What is reorg and runstats in db2?

1 Answers  


Categories