Sorting & Limiting4 / 10
Up next

Sort by an alias

CREATE TABLE rectangle (id INTEGER, width REAL, height REAL);
INSERT INTO rectangle VALUES (1, 4.0, 3.0), (2, 2.0, 2.0), (3, 5.0, 5.0);
-- ORDER BY can reference an alias from the SELECT list
SELECT id, width * height AS area
FROM rectangle
ORDER BY area;
What you're solving

ORDER BY a result-column name