Need SQL Logic For Comparing Data Between Two Tabless [message #682806] |
Fri, 20 November 2020 18:35  |
 |
nrk1979
Messages: 1 Registered: November 2020
|
Junior Member |
|
|
Hi!
Table1:
Acct Cust Owner Name
1111 A111 PRIM Dan Jason
1111 B111 SECO Donna Jason
1111 C111 SECO July Jason
Table2:
Acct Cust Owner Name
2222 A111 PRIM Donna Jason
2222 C111 SECO July Jason
2222 DD22 SECO Jimmy James
I have to compare both the (table1.Cust and table1.Name) fields against the (Table2.Cust and Table2.Name) fields.
Since one customer in Table 1 and Table 2 are different (Dan Jason and Jimmy James) and all others are similar, I need to report both account numbers 1111 and 2222 stating that the customers are different.
This is like vlookup in excel. However, I am not sure if this is possible in Oracle. Can someone guide me?
|
|
|
|
|
Re: Need SQL Logic For Comparing Data Between Two Tabless [message #682813 is a reply to message #682806] |
Sat, 21 November 2020 07:30  |
Solomon Yakobson
Messages: 3214 Registered: January 2010 Location: Connecticut, USA
|
Senior Member |
|
|
nrk1979 wrote on Fri, 20 November 2020 19:35
Since one customer in Table 1 and Table 2 are different (Dan Jason and Jimmy James) and all others are similar, I need to report both account numbers 1111 and 2222 stating that the customers are different.
So by different you mean both accounts have same customer but with different names. And if one account has customer that doesn't exist in other account that's similar (strange). If so:
select t1.Acct,
t2.Acct
from table1 t1,
table2 t2
where t1.cust = t2.cust
and t1.name != t2.name
/
SY.
|
|
|