IniziaInizia gratis

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.

Questo esercizio fa parte del corso

PostgreSQL Summary Stats and Window Functions

Visualizza il corso

Istruzioni dell'esercizio

  • Return all athletes and the first athlete ordered by alphabetical order.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

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;
Modifica ed esegui il codice