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: Can I use Aggregate Functions and convertion function togather?

Re: Can I use Aggregate Functions and convertion function togather?

From: andrewst <member14183_at_dbforums.com>
Date: Fri, 04 Jul 2003 12:40:19 +0000
Message-ID: <3075247.1057322419@dbforums.com>

Originally posted by Carfield Yim
> Hi, I've a column which the datatype is varchar, but all data store
> there is real number (I know that this is schema design problem, but I
> can't change that)
>
> Now I need to select the average of all record of that column, group
> by some other criteria, I would like to know can I use convertion
> function inside an aggregate function? Is this operation portable?
>

Why didn't you just try it? Yes you can:

SQL> select max(to_char(sal)) from emp;

MAX(TO_CHAR(SAL))



950

(I converted NUMBER to VARCHAR2 rather than other way because that's what I had to hand).

Portable? You mean to SQL Server etc.? In that case you should use ANSI SQL:

SQL> select max(cast(sal as varchar2(10))) from emp;

MAX(CAST(S



950
--
Posted via http://dbforums.com
Received on Fri Jul 04 2003 - 07:40:19 CDT

Original text of this message

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