5 ms·
As one of the comments notes, ORDER BY in subqueries is sometimes used for implementing pagination. I only have a limited amount of experience with SQL Server,
by AlisdairO 13y ago
As one of the comments notes, ORDER BY in subqueries is sometimes used for implementing pagination. I only have a limited amount of experience with SQL Server, but you ought to be able to accomplish the same using window functions:
SELECT blah FROM
(SELECT blah , ROW_NUMBER OVER(ORDER BY blah) num from mytable) as subq
WHERE num < 10
Of course, it's anyone's guess how efficiently SQL Server will optimise that :-).
- masklinn 13y agoThat is correct: http://troels.arvin.dk/db/rdbms/#select-limit-offset http://troels.arvin.dk/db/rdbms/#select-limit-offset Although note that if you're one of the Cursed Few who still has to use SQL Server 2000, you don't have ROW_NUMBER.
- AlisdairO 13y agoThat's a useful site, thanks!