How to select the duplicate rows from a table?

Answers were Sorted based on User's Feedback



How to select the duplicate rows from a table?..

Answer / nans

Select FIELD1 From <TABLENAME> As Temp Group By FIELD1 Having
Count(*) >1;

Is This Answer Correct ?    14 Yes 1 No

How to select the duplicate rows from a table?..

Answer / channabasappa

select field name from tablename where group by field name
having count(field name)>1;

Is This Answer Correct ?    1 Yes 0 No

How to select the duplicate rows from a table?..

Answer / mahesh vasudevan

Select <col-name> from table A1 and A2
where A1.Col = A2.Col.

This should be an inner join. Then you are finding the
intersection of the key values...if you want to find the
duplicates for all matching column of the rows code AND
condition for join with all those columns.....by the way
there are different easy ways to find it. but this is one of
the way.

Is This Answer Correct ?    0 Yes 0 No

How to select the duplicate rows from a table?..

Answer / pandu

select distinct from <field name> from <table name>

Is This Answer Correct ?    0 Yes 3 No

Post New Answer

More DB2 Interview Questions

Is there any advantage to denormalizing DB2 tables?

1 Answers  


How to find last record before record through SQLRPGLE?

1 Answers   IBM,


in the CURSOR declare statement, if i am using an where clause and trying to compare the value with a host-varialble. EXEC SQL DECLARE C1 CURSOR FOR SELECT DEPTNO, DEPTNAME, MGRNO FROM DEPARTMENT WHERE ADMRDEPT = :ADM-DEPT Where would i need to provide value to this host-variable in the where clause. how could i pass value to this host-variable to check it.

2 Answers   iGate,


What happens to the PLAN if index used by it is dropped?

1 Answers  


What is the purpose of the QUIESE Utility?

1 Answers  






i have a table like this : Name ADDRESS Toto 123 ... Toto 456 ToTo 678 I would like to delete 2 last row...please tell me how to delete its

5 Answers   EDS,


I have a main program (A) where we delete some rows in table in a cursor, and we commit it in sub program(B). What will happen - will we get an error or not?

2 Answers  


What is subquery ?

6 Answers  


Why select is not preferred in embedded sql programs?

0 Answers  


what is the role of the cursor in db2?

0 Answers  


SET is the ANSI standard for variable assignment, SELECT is not. SET can only assign one variable at a time, SELECT can make multiple assignments at once. If assigning from a query, SET can only assign a scalar value. If the query returns multiple values/rows then SET will raise an error. SELECT will assign one of the values to the variable and hide the fact that multiple values were returned (so you'd likely never know why something was going wrong elsewhere - have fun troubleshooting that one) When assigning from a query if there is no value returned then SET will assign NULL, where SELECT will not make the assignment at all (so the variable will not be changed from it's previous value) As far as speed differences - there are no direct differences between SET and SELECT. However SELECT's ability to make multiple assignments in one shot does give it a slight speed advantage over SET.

0 Answers  


How do you find the maximum value in a column in db2?

0 Answers  


Categories