I'm having problems figuring out how to reconcile records against two tables. Table 1 will contain records from one system and Table 2 will contain records from another system. Both tables will have an ID column unique to itself. It's possible that Table 1 will contain similar records, but with a different ID and the same for Table 2.
Table 1
ID | Acct_Num | Amount | Dt
---------+-----------+---------+-------------
96 | 5836 | 75 | 2020-04-02
100 | 5836 | 75 | 2020-04-02
Table 2
ID | Acct_Num | Amount | Dt
---------+-----------+---------+-------------
3 | 5836 | 75 | 2020-04-02
39 | 5836 | 75 | 2020-04-03
When I try to join on Acct_Num and Amount, the result returns 4 records, both records in Table 1 matching to both records in Table2.
SELECT * FROM Table1 t1 INNER JOIN Table 2 ON t1.Acct_Num = t2.Acct_Num AND t1.Amount = t2.Amount
ID | Acct_Num | Amount | Dt | ID | Acct_Num | Amount | Dt
---------+-----------+---------+-------------+-----------+-----------+---------+-------------
96 | 5836 | 75 | 2020-04-02 | 3 | 5836 | 75 | 2020-04-02
96 | 5836 | 75 | 2020-04-02 | 39 | 5836 | 75 | 2020-04-03
100 | 5836 | 75 | 2020-04-02 | 3 | 5836 | 75 | 2020-04-02
100 | 5836 | 75 | 2020-04-02 | 39 | 5836 | 75 | 2020-04-03
I understand this is how joins work, but what I'm looking to accomplish is to have a record on the left to match with just one record on the right. I don't care which one. The next record on the left will then match against the next available record on the right. Ending result as:
ID | Acct_Num | Amount | Dt | ID | Acct_Num | Amount | Dt
---------+-----------+---------+-------------+-----------+-----------+---------+-------------
96 | 5836 | 75 | 2020-04-02 | 3 | 5836 | 75 | 2020-04-02
100 | 5836 | 75 | 2020-04-02 | 39 | 5836 | 75 | 2020-04-03
I'm a bit lost on how I could accomplish this. Any suggestion would be helpful!