Sorting & Limiting5 / 10
Up next

Sort by several keys

CREATE TABLE player (id INTEGER, team TEXT, score INTEGER);
INSERT INTO player VALUES (1, 'Red', 10), (2, 'Blue', 10), (3, 'Red', 25);
-- sort by team, then score descending within each team
SELECT team, score
FROM player
ORDER BY team ASC, score DESC;
What you're solving

tie-break with more columns