Hacker News new | past | comments | ask | show | jobs | submit login

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 :-).



That is correct: 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.


That's a useful site, thanks!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: