When I try to run the following query i get ORA:missing expression. the is becomes highlighted on line marked this line =====>
select sub.*,
a.apat_code,
dx.dx_desc,
case
when LatestAppt is null then round((floor(sysdate - to_date(sub.refl_date))/30
.4),1)
when LatestAppt is not null then round((floor(sysdate - LatestAppt)/30.4),1)
end as Months_Waiting
from
(
select
r.pt_code,
r.refr_code,
cpi.surname,
r.refl_date,
max(a.appt_date) as LatestAppt,
r.hosp_code,
r.refp_code,
r.dept_code,
d.dept_title,
r.event_no,
r.clnp_code,
r.dsch_date,
r.cons_md_code,
r.ref_md_code,
r.dom_code
from
k_reflreg r,
k_apptreg a,
k_cpireg cpi,
k_deptlist d
where
r.event_no = a.event_no(+)
and r.annlappt_date is null
and r.pt_code = cpi.pt_code
and d.dept_code = r.dept_code
and r.dept_code = upper(:DeptCode)
and d.hosp_code = r.hosp_code
this line====> and ((a.appt_date is null) and (and r.refr_code != 'FSA')) <========this line
group by
r.pt_code,
r. refr_code,
cpi.surname,
r.refl_date,
r.hosp_code,
r.refp_code,
r.dept_code,
r.event_no,
r.clnp_code,
r.dsch_date,
r.cons_md_code,
r.ref_md_code,
r.dom_code,
d.dept_title
where ((LatestAppt < sysdate) or (LatestAppt is null))
and a.event_no(+) = sub.event_no
and a.appt_date(+) = sub.LatestAppt
and a.xtend_ind(+) = 'Y'
and dx.event_no(+) = sub.event_no
and dx.dx_type(+) = 'A'
order by months_waiting desc
Start Free Trial