By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,586 Members | 2,445 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,586 IT Pros & Developers. It's quick & easy.

DB2 Queries

P: n/a

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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.