Skip to content

2175. The Change in Global Rankings

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
SELECT
  TeamPoints.team_id,
  TeamPoints.name,
  CAST(
    RANK() OVER(
      ORDER BY TeamPoints.points DESC, TeamPoints.name
    ) AS SIGNED
  ) -
  CAST(
    RANK() OVER(
      ORDER BY TeamPoints.points + PointsChange.points_change DESC,
        TeamPoints.name
    ) AS SIGNED
  ) AS rank_diff
FROM TeamPoints
INNER JOIN PointsChange
  USING (team_id);