Advertisement

03.24.2008 at 02:34PM PDT, ID: 23265430
[x]
Attachment Details

Query problem 'missing expression'

Asked by deNZity in Oracle Database

Tags: ,

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
 
Loading Advertisement...
 
[+][-]03.24.2008 at 02:37PM PDT, ID: 21197212

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Oracle Database
Tags: oracle, 10g
Sign Up Now!
Solution Provided By: angelIII
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628