Quartiles
SQL practice problem 51 of 67 · Window Functions · Medium · 25 coins for your first accepted solve
Rank players by level descending (ties by name) and split them into 4 groups as evenly as possible, numbered 1 (top) to 4.
Return name, level, quartile, in rank order.
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: First Purchase · Next: Time Between Logins · All problems