Syntax:
|
SELECT TOP n select_list FROM T |
Get top n records |
|
SELECT select_list FROM T LIMIT n OFFSET m |
Skip m records to get n records |
Example:
|
SELECT top 10 EmpID,Name,Title,BirthDate ,HireDate,Boss,HomeCity FROM Employee ORDER BY BirthDate
|
Sort by BIRTHDAY in ascending order and get information of first 10 eldest employees |
|
SELECT CustomerID,ID,RDate,Amount,SellerID FROM ReturnedPmt ORDER BY Amount LIMIT 20 OFFSET 10 |
Sort by Amount in ascending order and get records whose amounts are the lowest from the 20th to the 30th |
|
SELECT top * FROM ReturnedPmt BY CustomerID order by Amount desc |
Group records by CustomerID, get the record having the largest Amount value and concatenate the eligible records |