How does varchar2 sorting in oracle works?

4k views Asked by At

I'm sorting a Oracle SQL query by a Varchar2 column. But when I get the results i can not correctly understand the ordering. Which is the logical order. first lower letters? numbers? symbols?. Here I attach the resulting ordering of one of the tests:

select FieldToOrder from MyTable order by FieldToOrder ASC

being FieldToOrder a VARCHAR2 column


FieldToOrder:

" 77777777777" //The first character is a blank space

"aaas"

"_aad"

"AADD"

"A00004AAAA9999"

"ref11"

"ref22"

"0000000002222"


Any ideas of what's the logical order? Thanks,

1

There are 1 answers

1
Benoit On BEST ANSWER

It depends on the environment variable NLS_LANG on your client side. See this reference on NLS_SORT.