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 db2 isolation?

2 Answers  


How to get Top 10 Salaries from a Table

11 Answers   Accenture, HTC,


run jcl for cobol+db2 pgm?.. //jobcard //step001 exec pgm=ikjeft01 //systin dd * DSNSYSTEM(--------) RUN PROGRAM(MYPGMNAME) PLAN(-----), LIB(-------), PARMS(------) /* WHAT WILL U GIVE INSIDE THE BRACKETS... WHAT IS PLAN,PACKAGE,BIND?..PLAN N PACAKGES ARE GENERATED BY ?...

0 Answers   IBM,


What is db2? Explain.

0 Answers  


What is ibm db2 database?

0 Answers  






Say CUST Table contains records like: CUSTNO CUSTNAME CUSTLOC 100 ABC SSS 200 XYZ 300 PQR 400 MNO WWW 500 CVV ------------- ------------- Now write a query to retrieve all records with CUSTLOC no data.

3 Answers   IBM,


What can the Locate option of the Repair Utility accomplish?

2 Answers  


What is the error code -803 ?

3 Answers  


which authority can be granted to group of users using the GRANT stmt? A) SYSCTRL B) SYSADM C) DBCTRL D) DB ADM

3 Answers   Accenture,


what is REORG? what is the use?

4 Answers  


what is the input to PLAN? what is the input to DBRM?

4 Answers  


What are leaf pages?

3 Answers  


Categories