First queries · Sort and limit
Order matters
Without ORDER BY, a database may return rows in any order. Add ORDER BY column to sort ascending, or ORDER BY column DESC for descending.
LIMIT n keeps only the first n rows. It always goes last.
Go deeper: SQL ORDER BY and LIMIT
Try it
SELECT name, age FROM pets ORDER BY age DESC LIMIT 5;
Press Enter to continue