SQL SELECT TOP
The SELECT TOP statement is used in SQL to retrieve a specified number of rows from a result set. It is particularly useful when you want to limit the number of rows returned by your query.
Syntax
The basic syntax of the SELECT TOP
statement is:
SELECT TOP (number) column1, column2, ...
FROM table_name
WHERE condition;
Example
Here is an example of how to use the SELECT TOP
statement to retrieve the top 5 employees with the highest salaries:
-- Example: Selecting top 5 rows
SELECT TOP 5 EmployeeID, FirstName, LastName, Salary
FROM Employees
ORDER BY Salary DESC;