SQL Server Interview Question #53
What is TOP in SQL Server?
SELECT, Filtering, Sorting & Built-in Functions Mid-Level Intermediate
Detailed Explanation
TOP limits the number or percentage of rows returned or affected. When TOP is used to obtain a meaningful first or last set of rows, it should normally be paired with ORDER BY.
TOP can also use PERCENT and WITH TIES. WITH TIES can return additional rows that have the same ORDER BY value as the last selected row.
Code Example
SELECT TOP (10)
Id, Name, Price
FROM dbo.Products
ORDER BY Price DESC;