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:
ASCis usually the default; useDESCfor top values.- Without
ORDER BY,LIMITalone is not a stable ranking. - Dialects differ (
LIMIT,FETCH FIRST,TOP) — learn the idea, then the vendor form.
Check
Check understanding
Discussion
Comments
Share feedback or questions about this page. No account required.
Loading comments…