Created
July 20, 2012 05:16
-
-
Save waynerobinson/3148825 to your computer and use it in GitHub Desktop.
Oracle - SELECT ordered with LIMIT and OFFSET
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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