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

select distinct(empid),distinct(dept),name from EMP will the above query work?

2 Answers   CTS,


What are packages in db2?

0 Answers  


In db2, how do you insert multiple rows in 1 query using a.) Cursors, b.) Normal query?? Give syntax for both.

5 Answers   CTS,


If I have 5 Queries in a DB2 Cobol program , while precompiling how many DBRMs will get created and How many Plans and Packages will get created while Bind Process?

8 Answers   Accenture,


If the base table underlying a view is restructured, eg. attributes are added, does the application code accessing the view need to be redone?

2 Answers  


Q3. How will you fetch duplicate values from a DB2 table?

2 Answers   RBS,


How do you insert a record with a nullable column?

2 Answers  


What is the role of schema in the db2 database?

0 Answers  


Explain about open switch business continuity software?

0 Answers  


Are views updateable?

0 Answers  


What is syscat in db2?

0 Answers  


What is db2 plan table?

0 Answers  


Categories