I suppose your NLS_SORT
parameter is BINARY
. In BINARY
sort, the strings are sorted as their binary expression, which means that the uppercase letters will be coming before the lowercase letters:
SQL> alter session set nls_sort=binary;
Session altered
SQL> select model from client_source order by model;
MODEL
--------------------
1234
4g
Default
Unknown
default1
ipad
iphone
iphone simulator
ipod
ipod touch
test
You can change this behaviour with different NLS_SORT
values. Use a value of NLS_SORT
with the _CI
suffix to make it case-insensitive:
SQL> alter session set nls_sort=latin_ci;
Session altered
SQL> select model from client_source order by model;
MODEL
--------------------
Default
default1
ipad
iphone
iphone simulator
ipod
ipod touch
test
Unknown
1234
4g
You can move the digits at the front with a CASE
:
SQL> SELECT model
2 FROM client_source
3 ORDER BY CASE WHEN regexp_like(model, '^[[:digit:]]')
4 THEN 0
5 ELSE 1
6 END,
7 model;
MODEL
--------------------
1234
4g
Default
default1
ipad
iphone
iphone simulator
ipod
ipod touch
test
Unknown
Additionally, you can use the NLSSORT
function to modify the sorting preference of a single query:
select model from client_source order by NLSSORT(model, 'NLS_SORT = LATIN_CI');