TOP
TOP is a keyword in SQL that is used to specify the number of records to return from a query or view. It can be particularly useful for limiting the number of rows in the result set of a query.
Example
SELECT TOP 3 * FROM Orders;
Output
OrderID | CustomerID | EmployeeID | OrderDate---------------------------------------------------10248 | 90 | 5 | 1996-07-0410249 | 81 | 6 | 1996-07-0510250 | 34 | 4 | 1996-07-08
Explanation
The TOP
keyword is used to specify the number of records to return from top of the dataset. In the given example, the first 3 records from the Orders
table are returned.