Re: Convert Char to Num
Posted in 1997
In article <01bca658$9b6bd700$44cd09c0@dam>,
Damien <damien_chambe@cornut.fr> wrote:
>
>Is there a function to convert a CHAR to a Numeric format ?
>I want to make a SUM from a column wich contains some numeric data,
>but the type of the column is CHAR and I can't change it.
"+ 0" seems to do the trick:
create temp table t1 ( char_data char(10) ) with no log ;
insert into t1 values ( "100" ) ;
insert into t1 values ( "105" ) ;
insert into t1 values ( "-50" ) ;
select char_data + 0 from t1 ;
select sum ( char_data + 0 ) from t1 ;
which returns:-
(expression)
100.00
105.00
-50.00
3 row(s) retrieved.
(sum)
155.00
1 row(s) retrieved.
- Paul (who is still here too)