Hi All,
I am having difficulties for sum() function, getting ORA-01722: Invalid Number error.
Problem:
My following simple query working fine in both Oracle(Toad) and Crystal Report (SQL Expression)
select
sa.acct_id,
adjc.char_val KWH
from cisadm.ci_ft ft, cisadm.ci_sa sa, cisadm.ci_adj_char adjc
where ft.parent_id = 'FIT'
and sa.sa_id = ft.sa_id
and adjc.adj_id = ft.sibling_id
and adjc.char_type_cd= 'KWH'
and trunc(ft.freeze_dttm) < to_date('2013-06-30', 'YYYY-MM-DD')
Now when I am trying to do SUM KWH for each Acct_ID, getting invalid Number error in Crystal report (SQL Expression) but fine in Oracle (Toad).
My New Query:
select
fit.acct_id,
sum(fit.kwh) kwh,
from
(
select
sa.acct_id,
adjc.char_val KWH
from cisadm.ci_ft ft, cisadm.ci_sa sa, cisadm.ci_adj_char adjc
where ft.parent_id = 'FIT'
and sa.sa_id = ft.sa_id
and adjc.adj_id = ft.sibling_id
and adjc.char_type_cd= 'KWH'
and trunc(ft.freeze_dttm) < to_date('2013-06-30', 'YYYY-MM-DD')
) fit
group by fit.acct_id,fit.kwh;
Issue:
Column adjc.char_val has Varchar2 datatype and i have to convert into Number. when I used to_number(adjc.char_val)kwh function in my first query, got ORA-01722: Invalid Number error and without to_number function my first query is okay. when I use SUM function in my Second query, I am getting same ORA-01722: Invalid Number error again. I tried to use store Procedure, but getting same error.
Could you please let me know any workaround how do I get Sum value for each Acct_ID.
Appreciate that.
Thanks.
I am having difficulties for sum() function, getting ORA-01722: Invalid Number error.
Problem:
My following simple query working fine in both Oracle(Toad) and Crystal Report (SQL Expression)
select
sa.acct_id,
adjc.char_val KWH
from cisadm.ci_ft ft, cisadm.ci_sa sa, cisadm.ci_adj_char adjc
where ft.parent_id = 'FIT'
and sa.sa_id = ft.sa_id
and adjc.adj_id = ft.sibling_id
and adjc.char_type_cd= 'KWH'
and trunc(ft.freeze_dttm) < to_date('2013-06-30', 'YYYY-MM-DD')
Now when I am trying to do SUM KWH for each Acct_ID, getting invalid Number error in Crystal report (SQL Expression) but fine in Oracle (Toad).
My New Query:
select
fit.acct_id,
sum(fit.kwh) kwh,
from
(
select
sa.acct_id,
adjc.char_val KWH
from cisadm.ci_ft ft, cisadm.ci_sa sa, cisadm.ci_adj_char adjc
where ft.parent_id = 'FIT'
and sa.sa_id = ft.sa_id
and adjc.adj_id = ft.sibling_id
and adjc.char_type_cd= 'KWH'
and trunc(ft.freeze_dttm) < to_date('2013-06-30', 'YYYY-MM-DD')
) fit
group by fit.acct_id,fit.kwh;
Issue:
Column adjc.char_val has Varchar2 datatype and i have to convert into Number. when I used to_number(adjc.char_val)kwh function in my first query, got ORA-01722: Invalid Number error and without to_number function my first query is okay. when I use SUM function in my Second query, I am getting same ORA-01722: Invalid Number error again. I tried to use store Procedure, but getting same error.
Could you please let me know any workaround how do I get Sum value for each Acct_ID.
Appreciate that.
Thanks.