467,202 Members | 1,016 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,202 developers. It's quick & easy.

DB2 Queries


How we can eliminate duplicate records using SQL query.

Problem is :

Suppose there are two tables: TABLE1 (10 columns) & TABLE2(7 columns).

I need to eliminate duplicate from these two tables. 5 columns are
common in these
tables. With the help of Group By,Order By and Having condition how we
can eliminate
duplicates.
Can anyone give me more information regarding this.
Thanks,
Pradeep

Apr 16 '06 #1
  • viewed: 1157
Share:
3 Replies
Pradeep wrote:
How we can eliminate duplicate records using SQL query.

Problem is :

Suppose there are two tables: TABLE1 (10 columns) & TABLE2(7 columns).

I need to eliminate duplicate from these two tables. 5 columns are
common in these
tables. With the help of Group By,Order By and Having condition how we
can eliminate
duplicates.
Can anyone give me more information regarding this.

Can you provide example data and output?
Given that you have two tables it's not obvious what you mean by
duplicate records. Also it's important to know whether there is a
primary key.
You are on DB2 zOS?

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Apr 16 '06 #2
select table1.columns1,
table1.columns2,
table1.columns3,
table1.columns4,
table1.columns5,
from TABLE1
union
select table2.columns1,
table2.columns2,
table2.columns3,
table2.columns4,
table2.columns5,
from TABLE2
will reasult in rows with out duplicate records

Apr 16 '06 #3
I will Try this Method and will send feedback ASAP.
Thank You,
Ratnam

Apr 25 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Dom Boyce | last post: by
reply views Thread by MHenry | last post: by
44 posts views Thread by Greg Strong | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.