Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. SELECT
  2. user_id,
  3. team_id,
  4. highestScore,
  5. RANK() OVER (PARTITION BY team_id ORDER BY highestScore DESC) AS teamRank,
  6. RANK() OVER (ORDER BY highestScore DESC) AS globalRank
  7. FROM (
  8. SELECT
  9. user_id,
  10. team_id,
  11. MAX(score) AS highestScore
  12. FROM score
  13. GROUP BY user_id, team_id
  14. ) AS t
  15. ORDER BY team_id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement