I have table like below and Want to generate a round robin match schedule.
Input Table.
TID PlayerID
2 14
2 1
2 21
2 37
2 17
Output
14 V 1
14 V 21
14 V 37
14 V 17
1 V 21
1 V 37
1 V 17
21 V 37
21 V 17
37 V 17
If you want all possible combinations regardless or left/right order you can do:
select
a.player_id,
b.player_id
from player a
join player b on b.player_id < a.player_id