SQL UNION query remove duplciates based on specific columns
779550Jul 28 2011 — edited Jul 28 2011Hi,
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