Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: order by/case expression problem

Re: order by/case expression problem

From: Svend Jensen <Master_at_OracleCare.Com>
Date: Sat, 08 Dec 2001 11:20:58 +0100
Message-ID: <3C11E98A.60A7F3C1@OracleCare.Com>


Cyber Office wrote:
>
> The last select statement in the following batch seems to return incorrect
> result.
>
> Am I right?
>
> --------------------------------------------------------------------------
> drop table d
> create table d (d char(10))
> insert into d values ('1')
> insert into d values ('10')
> insert into d values ('9')
>
> select d from d order by d
> d
> ----------
> 1
> 10
> 9
>
> select d from d order by cast(d as numeric)
> d
> ----------
> 1
> 9
> 10
>
> select d from d order by
> case when 1 = 1 then 1 else cast(d as numeric) end
> d
> ----------
> 1
> 10
> 9
>
> select d from d order by
> case when 1 = 1 then d else cast(d as numeric) end
> d
> ----------
> 1
> 9
> 10
>
> --
> http://www-902.ibm.com/hk/sme/corner/solution_detail.html#a3
> http://www.attunity.com

Hi

Your select has a implicit to_number conversion (1 = 1), might try with 1 = '1'

/svend Received on Sat Dec 08 2001 - 04:20:58 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US