语法描述:
SELECT TOP n select_list FROM T |
取前n条记录 语句中有by时根据order by取每个组前n条数据,再取并集;暂不支持有union的情况;n缺省为1,且根据order by选出每组最大/最小的成员数据 |
SELECT select_list FROM T LIMIT n OFFSET m |
跳过m条后取n条记录 |
举例:
SELECT top 10 EmpID,Name,Title,BirthDate ,HireDate,Boss,HomeCity FROM Employee ORDER BY BirthDate |
根据BIRTHDAY升序排序 ,取年龄最大的前10个员工的信息 |
SELECT CustomerID,ID,Date,Amount,SellerID FROM ReturnedPmt ORDER BY Amount LIMIT 20 OFFSET 10 |
根据Amount升序排序,取Amount最小的第20到第30条记录 |
SELECT top * FROM ReturnedPmt BY CustomerID order by Amount desc |
按照CustomerID分组,选出每组中Amount最高的记录并列返回 |