3

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,

Fgblanch
  • 5,195
  • 8
  • 37
  • 51

1 Answers1

3

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

Benoit
  • 76,634
  • 23
  • 210
  • 236
  • 1
    By default it uses binary representation for sorting, it can be changed to linguistic and customized for monolanguage or multilanguage . More info: http://download.oracle.com/docs/cd/B28359_01/server.111/b28298/ch5lingsort.htm#insertedID0 – Fgblanch Mar 07 '11 at 12:38