I am executing below sql not getting expected result, I am converting the columns into NUMBER(19,10) before division but I need the result (after division) to be converted into NUMBER (19,10);
SELECT DISTINCT
CAST(TO_NUMBER(BASE_AMT) AS NUMBER (19,10))/CAST(TO_NUMBER(ACT_AMT) AS NUMBER (19,10))
FROM CUSTOMER;
Note: BASE_AMT and ACT_AMT columns are varchar2 defined
>Solution :
You should have probably applied cast function to final result, e.g.
SQL> create table customer (code varchar2(3), name varchar2(8), base_amt varchar2(5), act_amt varchar2(5));
Table created.
SQL> insert into customer (code, name, base_amt, act_amt) values ('100', 'Scott', '33', '4');
1 row created.
Like this:
SQL> select distinct
2 cast(to_number(base_amt) / to_number(act_amt) as number (19,10)) result
3 from customer;
RESULT
----------
8,25
SQL>