Beginner

344. TOP Clause

Learn how to return a specified number of rows using SQL Server TOP.

📘 Lesson 344 of 728 ⏱ 8 min 🎯 Beginner

TOP is a SQL Server clause used to limit the number or percentage of rows returned by a query.

TOP is especially important when working with SQL Server and when creating reports that require a fixed number of records.

Return the 10 highest-paid employees.

SQL
SELECT TOP 10
    EmployeeName,
    Salary
FROM Employees
ORDER BY Salary DESC;

TOP is useful for ranking reports, previews, top-performer analysis, and SQL Server data exploration.

  • TOP limits returned rows in SQL Server.
  • TOP can be combined with ORDER BY.
  • ORDER BY is important for meaningful top results.
  • TOP can also support percentages.
  • Other databases use different row-limiting syntax.
What is TOP used for?

TOP is used in SQL Server to limit the number of rows returned by a query.

Why should TOP often be combined with ORDER BY?

ORDER BY determines which rows are considered the top rows.

Have you finished this lesson?

Introduction to SQL – All Lessons