java - MS SQL vs Oracle Order By -
i'm confronted guess oracle nulls problem - not sure - oracle giving me different result ms sql. column (day) trying order date/time column , id column varchar:
here, on left result way want - same sql oracle i'm getting different(read: wrong) result. far i've looked in internet has fact cannot find c ids on 2015-01-01 , 2015-01-02 - thats why pushes sole c result in beginning. whats more strange fact not order right -
ms sql server:
2015-01-01 2015-01-01 2015-01-02 2015-01-02 2015-01-03 2015-01-03 2015-01-03
oracle:
2015-01-03 2015-01-01 2015-01-02 2015-01-03 2015-01-01 2015-01-02 2015-01-03
->the query quite simple:
select id,day dayidtable order day
in java web app - how can make sure use same sql caters both ms sql , oracle databases? appreciated! thanks.
i have 1 request please ! know result of oracle not make sense "theoretically" - thats - before question gets bloated "not possible" answers request people answer if have idea or hunch. alot.
anyone?
update:
if use following sql - oracle results work fine now:
select id,day dayidtable order day,id
but question remains why doesn't sort "day" ms sql?
if don't have same behaviour depending database can implement own comparator in java
side ensure sorting.
class mycomparator implements comparator<myclass> { public int compare(myclass ob1, myclass ob2) { return ob1.getday().compareto(ob2.getday()); // invert reverse order } }
Comments
Post a Comment