Example 1
Sort rows from highest score to lowest
Without ORDER BY, a database can return rows in any convenient internal order.
Source table data Rows loaded before the example query runs.
Setup
CREATE TABLE scores (player VARCHAR(50), points INT);
INSERT INTO
scores (player, points)
VALUES
('Ada', 42),
('Linus', 89),
('Grace', 65);Validated query Shared across supported engines.
SQL
SELECT
player,
points
FROM
scores
ORDER BY
points DESC,
player ASC;Expected result Returned rows for the shared example.
| player | points |
|---|---|
| Linus | 89 |
| Grace | 65 |
| Ada | 42 |
The result is only trustworthy because the query sets the row order explicitly.