First athlete by name
It's often useful to get the first or last value in a dataset to compare all other values to it. With absolute fetching functions like FIRST_VALUE
, you can fetch a value at an absolute position in the table, like its beginning or end.
This exercise is part of the course
PostgreSQL Summary Stats and Window Functions
Exercise instructions
- Return all athletes and the first athlete ordered by alphabetical order.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
WITH All_Male_Medalists AS (
SELECT DISTINCT
Athlete
FROM Summer_Medals
WHERE Medal = 'Gold'
AND Gender = 'Men')
SELECT
-- Fetch all athletes and the first athlete alphabetically
___,
___ OVER (
ORDER BY ___ ASC
) AS First_Athlete
FROM All_Male_Medalists;