Skip to content

Instantly share code, notes, and snippets.

@kennyp
Created August 23, 2012 20:27
Show Gist options
  • Save kennyp/3441263 to your computer and use it in GitHub Desktop.
Save kennyp/3441263 to your computer and use it in GitHub Desktop.
Because there is not a decent limit clause in MSSQL.
SELECT
*
FROM (
SELECT
ROW_NUMBER() OVER (ORDER BY last_name asc) AS RowNum,
phppos_people.*,
phppos_employees.username,
phppos_employees.deleted
FROM phppos_people
JOIN phppos_employees ON
phppos_people.person_id = phppos_employees.person_id
WHERE
deleted = 0
) AS MyEmployees
WHERE MyEmployees.RowNum BETWEEN 0 AND 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment