问题
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:
It depends on the environment variable NLS_LANG
on your client side. See this reference on NLS_SORT.
来源:https://stackoverflow.com/questions/5218560/how-does-varchar2-sorting-in-oracle-works