Hello:
I have a query where I would like to get total counts. The result of the query should look like this:
org clinician name yes no na total
1 123 brown 5 2 0 7
2 345 gray 1 1 1 3
etc....
When I run my query, I receive the following error message:
ORA-01722 - Invalid Number
The sub-query which I'm using to do my counts is based on a field named cmf_flag which is a varchar though it contains a numeric value. Here is the query where I'm going through the decode and to_number process:
select org_key,
clinician_key,
clin_name,
yes,
no,
na,
total
from
(select
clinician_key,
clin_name,
org_key,
count(decode(to_number(pi.cmf_flag),1,1)) YES,
count(decode(to_number(pi.cmf_flag),2,1)) NO,
count(decode(to_number(pi.cmf_flag),3,1)) NA,
count(pi.rowid) as TOTAL
from v_patient_info pi
where org_key = &orgkey
and program_key = &program_key
group by org_key, clinician_key, clin_name
)
order by org_key asc, clin_name asc;
Can someone help me?
Thanks