Excel to SQL · Lesson 3 of 12

Sort with ORDER BY

In Excel, you'd reach for
fxData > Sort (A to Z, Z to A, custom sort with levels)

ORDER BY sorts the result. Add DESC for largest first (Z to A), or leave it off for smallest first (A to Z).

Excel's "Add Level" in the custom sort box is just a second column after a comma: sort by region, then by quantity within each region.

Try itEdit the query, then Run
order_dateregionquantity
2026-01-06Asia Pacific6
2026-01-09Asia Pacific6
2026-01-20Asia Pacific6
2026-02-05Asia Pacific6
2026-02-19Asia Pacific6
2026-02-23Asia Pacific6
2026-02-25Asia Pacific6
2026-02-28Asia Pacific6
2026-03-04Asia Pacific6
2026-03-05Asia Pacific6

Showing 10 of 20 rows. Press Run to see them all.

Unlike sorting a sheet, this never rearranges the stored data. Every query gets its own sorted copy, so you can't break anything.

Your turn

List the 5 most expensive products: name and unit_price, most expensive first.

This page on one card

Sort with ORDER BY: the Excel way (Data > Sort (A to Z) and the SQL query, side by side
Sort with ORDER BY, on one card: the Excel way and the SQL. Download · Save to Pinterest
The practice data (7 tables)

See every column and sample rows