You can use the OVER clause and the ranking function. You cannot filter this directly, so you need a sub-query or a general table expression, the last one is used in the example below.
DECLARE @MyTable TABLE ( ID INT, Name VARCHAR(15) ) INSERT INTO @MyTable VALUES (1, 'Alice') INSERT INTO @MyTable VALUES (2, 'Bob') INSERT INTO @MyTable VALUES (3, 'Chris') INSERT INTO @MyTable VALUES (4, 'David') INSERT INTO @MyTable VALUES (5, 'Edgar') ;WITH people AS ( SELECT ID, Name, ROW_NUMBER() OVER (ORDER BY ID) RN FROM @MyTable ) SELECT ID, Name FROM people WHERE RN > 1
Pagination support will be improved in the next version of SQL Server (codename Denali) with the keywords OFFSET and FETCH .
Chris diver
source share