Click here to Skip to main content
15,888,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I know that the top clause is used to retrieve a 'maximum' of rows from the database.

however, is there a possibility to say "i want al the rows from 40 to 50.

I know that oracle database have the variable "rownum" which is usefull in such situations, is this also possible in Sql-Server 2005?

With kind regards.

The Amateurgrammer
Posted

try this

SQL
Select top 10 *
From MyTable
Where PrimaryKeyField Not In
(Select top 10 PrimaryKeyField
From MyTable
Order By MySequenceField)
Order By MySequenceField
 
Share this answer
 
Something like this would do it
SQL
SELECT  col1,
        col2,
        col3
FROM    (
        SELECT  col1,
                col2,
                col3,
                ROW_NUMBER() OVER( ORDER BY col1,col2) as rownum
        FROM    MyTable
        ) a
WHERE   rownum BETWEEN 40 AND 50
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900