Two columns from the same table with many to many relation. In other words, ID 1 can possibly match with matchID A or B. Meanwhile matchID A can possibly match with ID 1, 2 or 3.
| ID | matchID |
|---|---|
| 1 | A |
| 1 | B |
| 2 | A |
| 2 | B |
| 3 | A |
| 3 | C |
The output should have each ID linked with only one distinct matchID. For example, once ID 1 is linked with mathchID A, no other ID should match with matchID A.
I would like to get the following output:
| ID | matchID |
|---|---|
| 1 | A |
| 2 | B |
| 3 | C |
This query assumes that you want to prioritize the minimum ID when there are multiple matches for a given matchID. If you want to prioritize a different column, you can adjust the ORDER BY clause within the ROW_NUMBER() function accordingly