关于TOP (n) WITH TIES的运用
1 SELECT TOP (5) orderid, orderdate, custid, empid 2 FROM Sales.Orders 3 ORDER BY orderdate DESC, orderid DESC; 4 5 SELECT TOP (5) WITH TIES orderid, orderdate, custid, empid 6 FROM Sales.Orders 7 ORDER BY orderdate DESC;
上述代码执行结果:
即第二条SQL语句执行结果多了3条数据。这是因为WITH TIES能够请求返回与TOP n行中最后一行的排序值(即ORDER BY 的字段)相同的其他所有行。