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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Problems with CAST and order by

Re: Problems with CAST and order by

From: DA Morgan <damorgan_at_exesolutions.com>
Date: Thu, 16 Jan 2003 09:50:50 -0800
Message-ID: <3E26F0FA.BA9FF373@exesolutions.com>


"Francesco S. Rinaldi" wrote:

> I have this problem:
> This query is working:
> select distinct cast(history.object_id as varchar(14)),
> object_assembly.object, history.center from history, object_assembly where
> history.object_id like '30210314%' and history.object_id =
> object_assembly.object_id
>
> But I need to order the results by object_id, and it's not working.
> If I try simply to add
> order by object_id
> I get the following error message:
> DB: ERROR: ORA-00918 column ambiguosly defined
> The same error I get if I add
> order by cast(object_id as varchar(14))
> while if i try
> order by history.object_id
> I get
> DB: ERROR: ORA-01791 not a SELECTed expression
>
> How to solve this ?
>
> Thanks in advance,
> Francesco

Alias the column to which you have applied the CAST function.

For example:
select distinct cast(history.object_id as varchar(14)) CASTOBJID

Then order by CASTOBJID

Daniel Morgan Received on Thu Jan 16 2003 - 11:50:50 CST

Original text of this message

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