Skip to content

Instantly share code, notes, and snippets.

@nexocentric
Created October 28, 2014 18:38
Show Gist options
  • Save nexocentric/f2f6dcf7186c117d04d6 to your computer and use it in GitHub Desktop.
Save nexocentric/f2f6dcf7186c117d04d6 to your computer and use it in GitHub Desktop.
Oracle SQL: Natural Numeric Sort Order By Clause
--==========================================================
-- order by natural sort order as in
-- 1, 2.. 10, 11 and not computer sort order
--==========================================================
ORDER BY
to_number(regexp_substr(CHAR_COLUMN,'^[0-9]+')),
to_number(regexp_substr(CHAR_COLUMN,'[0-9]+$')),
CHAR_COLUMN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment