Page Actions
Wiki Actions
User Actions
Submit This Story

SQL Server select the #n to #m records

Since MS SQL Server don't provide rowid, This can be done with 'SELECT TOP':

SELECT TOP m-n+1 *   
    FROM SOME_TABLE   
    WHERE (SOME_KEY NOT IN(
               SELECT TOP n-1 SOME_KEY FROM SOME_TABLE))   

Discussion

Enter your comment
 
 
blog/2006/12/sql_server_select_the_n_to_m_records.txt · Last modified: 2006/12/01 00:00 (external edit)     Back to top
Recent changes RSS feed Creative Commons License Powered by PHP Driven by DokuWiki