Skip to content
Advertisement

Calculating the win/loss ratio per team

I have the following two tables:

sport_a_statistics:

sport_b_statistics:

I want to calculate the win/loss ratio for each team. This includes making sure to capture the wins and losses from both sport tables since my tournament involves 2 sports. So the output I’m looking for is the following:

I can’t wrap my head around how I would do this in one query.

Advertisement

Answer

Assuming you have no ties, you can use window functions and union all:


Made a small edit ^

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement