101
0/304
Loading content...
A football analytics platform stores club metadata and completed match results. The operations team needs a standings-style report that combines points and goal statistics for every club.
Table: teams
Table: matches
Scoring policy:
Task: For each team in teams, compute:
Output requirements:
Supported submission environments:
teams:
| team_id | team_name |
|---------|-----------|
| 1 | Ajax |
| 4 | Dortmund |
| 6 | Arsenal |
matches:
| home_team_id | away_team_id | home_team_goals | away_team_goals |
|--------------|--------------|-----------------|-----------------|
| 1 | 4 | 0 | 1 |
| 1 | 6 | 3 | 3 |
| 4 | 1 | 5 | 2 |
| 6 | 1 | 0 | 0 |[
{"team_name":"Dortmund","matches_played":2,"points":6,"goal_for":6,"goal_against":2,"goal_diff":4},
{"team_name":"Arsenal","matches_played":2,"points":2,"goal_for":3,"goal_against":3,"goal_diff":0},
{"team_name":"Ajax","matches_played":4,"points":2,"goal_for":5,"goal_against":9,"goal_diff":-4}
]Dortmund wins both matches for 6 points. Ajax and Arsenal both have 2 points, so goal difference decides their order.
teams:
| team_id | team_name |
|---------|----------------|
| 10 | Harbor City |
| 20 | River Athletic |
| 30 | Summit United |
| 40 | Metro Rovers |
matches:
| home_team_id | away_team_id | home_team_goals | away_team_goals |
|--------------|--------------|-----------------|-----------------|
| 10 | 20 | 1 | 0 |
| 30 | 10 | 2 | 2 |
| 20 | 30 | 3 | 1 |[
{"team_name":"Harbor City","matches_played":2,"points":4,"goal_for":3,"goal_against":2,"goal_diff":1},
{"team_name":"River Athletic","matches_played":2,"points":3,"goal_for":3,"goal_against":2,"goal_diff":1},
{"team_name":"Summit United","matches_played":2,"points":1,"goal_for":3,"goal_against":5,"goal_diff":-2},
{"team_name":"Metro Rovers","matches_played":0,"points":0,"goal_for":0,"goal_against":0,"goal_diff":0}
]Metro Rovers has no recorded matches and is still included with zeroed statistics.
teams:
| team_id | team_name |
|---------|-----------|
| 5 | Alpha FC |
| 7 | Beta FC |
| 9 | Gamma FC |
matches:
| (no rows) |[
{"team_name":"Alpha FC","matches_played":0,"points":0,"goal_for":0,"goal_against":0,"goal_diff":0},
{"team_name":"Beta FC","matches_played":0,"points":0,"goal_for":0,"goal_against":0,"goal_diff":0},
{"team_name":"Gamma FC","matches_played":0,"points":0,"goal_for":0,"goal_against":0,"goal_diff":0}
]With no matches available, every team has zero points and goals. Final ordering is by team_name.
Constraints