Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

SQL UNION query remove duplciates based on specific columns

779550Jul 28 2011 — edited Jul 28 2011
Hi,

I have got an sql union query on two tables. lets say T1 and T2.

each of those tables have three columns c1, c2 and c3 of type Number, Varchar and Timestamp respectively.

Now i have union query

Select c1, c2, c3 from T1
UNION
Select c1, c2, c3 from T2.

lets say I have a record in my table T1 with values 1, abc, 29-SEPT-2010 10:00:00

and one record in T2 with values 1, abc, 29-SEPT-2010 9:00:00


I want my query to pick up only one of these two records. ie I want it to check only the c1 and c2 columns while giving me the results for duplicate check. Also the problem is I cannot use the exist on the second select because the two tables are huge.


Thanks in advance
Paddy
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 25 2011
Added on Jul 28 2011
7 comments
1,271 views