Writing:
Pretend to have a table shop, which has a list of shopname, taking 100000 to 100,050 data.
The writing of Row_number
SELECT * from (
SELECT Over (ORDER by Shopname) as R from Shop
) TWHERE R>100000 and R<=100050
The writing of Offset,fetch
SELECT from Shop ORDER by shopname OFFSET 100000 ROW FETCH NEXT - only
Comparison:
The difference in execution time can be clearly seen when 100,000 data are taken. Although the previous people have given a lot of arguments, I will stick to the comparison results here.
First Row_number.
And then the OFFSET FETCH .
The latter is both efficient and well-written and understandable with wood!
Private Small notes:
offset= offset, skipping
FETCH = Fetch
Alternatively, offset can be used alone, as below, skipping the top 100,000:
SELECT from Shop ORDER by shopname OFFSET 100000 ROW
Off Topic:
From SQL SERVER 2000 The people are still writing top of the age, to 2005 of the Row_number, and then to 2012 of the offset FETCH, apes compatriots are really not with the tight trend is to be ruthlessly thrown down AH ~ together add a oil bar ~
SQL SERVER 2012/2014 Paging, overwriting the use of row_number with Offset,fetch next