Skip to content

Instantly share code, notes, and snippets.

@nexocentric
Created October 28, 2014 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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