Aan de slagGa gratis aan de slag

Numbering Olympic athletes by medals earned

Row numbering can also be used for ranking. For example, numbering rows and ordering by the count of medals each athlete earned in the OVER clause will assign 1 to the highest-earning medalist, 2 to the second highest-earning medalist, and so on.

Deze oefening maakt deel uit van de cursus

PostgreSQL Summary Stats and Window Functions

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

SELECT
  -- Count the number of medals each athlete has earned
  ___,
  ___ AS Medals
FROM Summer_Medals
GROUP BY Athlete
ORDER BY Medals DESC;
Code bewerken en uitvoeren