Skip to main content
SQL โ€ข LESSON 08

Sorting & Limiting Results

How can we return only the top N records from a sorted dataset?

Intermediateโฑ 2 Minutesโญ 160 XP
๐Ÿค” THE QUESTION

How can we return only the top N records from a sorted dataset?

๐Ÿ’ก WHAT IS IT?

LIMIT constrains the number of rows returned by a query, ideal when paired with ORDER BY.

๐ŸŽฏ WHAT IS IT USED FOR?

Pagination, top 10 rankings, sampling large tables, and quick exploratory analysis.

๐Ÿ’ป EXAMPLE
SELECT *
FROM employees
ORDER BY salary DESC
LIMIT 10;

๐ŸŽฏ Mission Objectives

Practice typing production-grade SQL code for Sorting & Limiting Results.

  • โœ“ ORDER BY
  • โœ“ LIMIT
  • โœ“ Top-N analysis
  • โœ“ Pagination