SQL Server OFFSET equivalent
Unfortunately SQL Server does not offer anything similar to MySQL's OFFSET
syntax. However, you may want to try using a derived table as follows:
SELECT some_field
FROM (
SELECT some_field, ROW_NUMBER() OVER (ORDER BY some_id) AS rownum
FROM table
) AS t
WHERE t.rownum BETWEEN 11 AND 20
See following solution is applicable only for SQL Server 2012 onwards.
Limit with offset in sql server:
SELECT email FROM myTable
OFFSET 10 ROWS
FETCH NEXT 10 ROWS ONLY;
//offset - no. of skipped rows
//next - required no. of next rows
Assuming a sort field PK,
select top 10 * from MyTable
where PK not in (select top 10 PK from Mytable order by PK)
order by PK
Edit: here's a variant
select top 10 * from
(select top 20 * from MyTable order by PK) as MySelection
order by PK desc