Skip to content

Instantly share code, notes, and snippets.

@waynerobinson
Created July 20, 2012 05:16
Show Gist options
  • Save waynerobinson/3148825 to your computer and use it in GitHub Desktop.
Save waynerobinson/3148825 to your computer and use it in GitHub Desktop.
Oracle - SELECT ordered with LIMIT and OFFSET
-- SELECT with LIMIT and OFFSET in MySQL
SELECT id, name FROM table ORDER BY name LIMIT 100 OFFSET 50;
-- SELECT with LIMIT and OFFSET in Oracle
SELECT a.id, a.name
FROM (SELECT b.id, b.name,
rownum b_rownum
FROM (SELECT c.id, c.name
FROM table c
ORDER BY b.name) b
WHERE rownum <= 100) a
WHERE b_rownum >= 50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment