how to get duplicate records from tables?write qurey for this?

Answers were Sorted based on User's Feedback



how to get duplicate records from tables?write qurey for this?..

Answer / anshuman

Select column_name1,column_name2
from table_T
group by column_name1 having count(*)>1

it will give all the duplicates value of column_name1

Is This Answer Correct ?    28 Yes 7 No

how to get duplicate records from tables?write qurey for this?..

Answer / mahesh babu

select column_name,count(*) from table_name group by
column_name having count>1.

Is This Answer Correct ?    6 Yes 2 No

how to get duplicate records from tables?write qurey for this?..

Answer / naresh k

select * from table_name;
The above qurey get duplicate record also because the
database store records like multi-set..
if we want get distinct records then use following query.
select distinct(attribute_name) from table name

Is This Answer Correct ?    0 Yes 15 No

how to get duplicate records from tables?write qurey for this?..

Answer / pandu

To get the duplicate records in a table use the query
Select distinct(deptno) from emp;
reply any one to me am i correct.

Is This Answer Correct ?    2 Yes 26 No

Post New Answer

More DB2 Interview Questions

How would you print the output of an SQL statement from SPUFI?

2 Answers  


What is a clustering index?

2 Answers  


Why do we need to create an alias if we can directly use the table name? What are the benefits of referring a table name by its alias? Also, when should we go for alias and when for synonyms?

1 Answers  


What is db2 bind process?

0 Answers  


What is null value in db2?

0 Answers  






Can we use group-by clause in sub-query? If 'yes' means,Will it be executed successfully or else If 'no' means why should we not using that method? Give me your suggestion please....

1 Answers  


How to design maps

1 Answers   Virtusa,


what is static sql? what is dynamic sql? Give me details

3 Answers  


Hi All, In a Cobol-DB2 program, I am fetching rows from 4 tables using cursor and then based on the a field present in that table, It processes the information accordingly..for example stat-c is one digit field..if stat-c is 'D' then the a row is deleted from table and written those details in to a file. If the stat-c is 'U' then a row is updated (hardcoded what to update)in a table and written those details in to a file. If the stat-c is 'I' then a row is inserted in a table and written those details in to two files. The issue is i have to include the intermediate commits. When an abend occurs, due to commit statement db2 tables will be saved, But there will be lose of file contents. When we resubmitting the job associated with this program there will be insert ,update and delete anomolies to avoid that what measures could be taken?. The intermediate commit is nothing but issuing commit after massive inserts, updates and deletes(sum of 500actions)

1 Answers  


How can tablespace be moved to another dasd volume that is allocated for that tablespace?

0 Answers  


what is the use of cursors?

3 Answers   iGate,


how can u retrieve the data from null values using applicaion program.

3 Answers   TCS,


Categories