Law one:
Select ID,OrderDate,row_num from
(select *,row_number() over (order by OrderDate)as row_num from row_number) collection
where row_num between 2nd 4
The row_num column is generated by the row_number() function
Law two:
With Collection as
(selectSalesOoderID,OrderDate,row_number() over(order by OrderDate)as RowNumber from row_number)
Select * from Collection where RowNumber between 2 and 4
(1) order by OrderDate defaults to ascending order (asc) and descending order to desc
(2) The datetime type value is 2015/7/2112:21:00
(3) The writing of with is called a common table expression
(4) row_number()over(partition by COL1 order by COL2) means grouping according to COL1 , and sorting according to COL2 within the group , and the value calculated by this function represents the number of each group after sorting ( continuously unique within the group )