1 · Read and filter · 8 MIN
Sort deliberately
Sort deliberately.
ORDER BY chooses the result order. ASC is ascending and DESC descending. LIMIT caps returned rows. When sorting values that may tie, add a unique column to make the order deterministic.
Think of a spreadsheet: select columns, keep relevant rows, and summarize the result.
Read the example
SELECT amount FROM expenses ORDER BY amount ASC;
Check the expected output
[[3],[5],[7]]
Your challenge
Return the two highest amounts in descending order.
Common trap
Row order is only guaranteed with ORDER BY.
Next lesson: Aggregate a result →