Ravindra BagaleCourses & study guides Track your progress

ORDER BY, DISTINCT and Top-N Results — Ravi Sir's Cards

All SQL cards

Revision cards

ORDER BY and Top-N. Managers often ask for the biggest orders or for a list of unique cities.
ORDER BY and Top-N · PNG

Interview cards

How do you get the top 5 orders by amount? Sort by amount from biggest to smallest with ORDER BY amount DESC, then add LIMIT 5.
How do you get the top 5 orders by amount? · PNG

Comparison cards

DISTINCT vs ORDER BY. DISTINCT removes repeated values, so each value shows once. ORDER BY puts the rows in sorted order.
DISTINCT vs ORDER BY · PNG