Skip to main content

ORDER BY and LIMIT

After you filter, sort and cap the result so reviewers and pipelines see a stable slice.

Watch​

Video coming soon

Learn​

SELECT product_id, revenue
FROM product_daily
WHERE day = DATE '2026-07-01'
ORDER BY revenue DESC
LIMIT 10;

Notes:

  • ASC is usually the default; use DESC for top values.
  • Without ORDER BY, LIMIT alone is not a stable ranking.
  • Dialects differ (LIMIT, FETCH FIRST, TOP) — learn the idea, then the vendor form.

Check​

Check understanding

What does ORDER BY do?
Why pair ORDER BY with LIMIT for “top N”?

Select all that apply

Discussion

Comments​

Share feedback or questions about this page. No account required.

Loading comments…