sql - Oracle order by upper(colname) does not give proper results for non string columns -


when there non-string(i.e. : varchar,date) column(col1) in oracle db, if do:

select * table order col1 asc 

it orders properly. (ie. date, orders oldest latest, numeric, lowest highest) if do, select * table order upper(col1) asc ordering not correct.

what cause behavior?

upper takes string , returns string. if col1 other string, have implicitly cast string before function executed. since output of upper function string, however, sort have use string sorting semantics, not sort semantics of col1. if col1 numeric, example

  • upper(9) returns string '9'
  • upper(10) returns string '10'

the string '9' comes alphabetically after string '10' is, presumably, problem you're seeing.

but if col1 not string, why bother converting upper case in order sort?


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -