The Runner-Up

SQL practice problem 38 of 67 · Subqueries & CTEs · Medium · 25 coins for your first accepted solve

Find the second highest distinct level among all players.

Return a single row with one column second_level. If there is no second distinct level, return NULL (still one row).

Schema

CREATE TABLE players (
  id         INT PRIMARY KEY,
  name       TEXT NOT NULL,
  country    TEXT,            -- NULL = unknown
  level      INT NOT NULL,
  joined_on  DATE NOT NULL,
  mentor_id  INT              -- another player's id, or NULL
);

Write your query in the browser, run it on the sample data, then submit it against hidden test data.

Previous: Founding Members · Next: Above the Local Average · All problems