lww19959(提问者)你好,这两个地方我都改了。
select * from(Select \'门诊\' fl ,obi.item_code,obi.item_name,ood.ordered_by_dept As dept_code ,dd.dept_name ,obi.item_class, a.account_indicator,
sum(obi.amount), sum(obi.costs) From outp_rcpt_master a,outp_bill_items obi,outp_order_desc ood,dept_dict dd
Where
a.rcpt_no = obi.rcpt_no
And obi.visit_date = ood.visit_date
And obi.visit_no = ood.visit_no
And ood.ordered_by_dept = dd.dept_code
--And a.account_indicator = \'1\'
And obi.item_class In (\'A\',\'I\')
And a.charge_type In (\'SI超转\',\'海淀农合\',\'本院职工\',\'SI在职\',\'SI退休\',\'SI在职外\',\'SI在职残\',\'SI医保退\',\'SI退异地\',\'SI退职残\',\'SI退休残\',\'SI医退职\',\'SI退职异\',\'SI农民工\',\'SI老\',\'SI小\',\'新农合\',\'SI无业\')
And obi.visit_date
Between to_date(\'${start} \',\'yyyy-MM-dd hh24:mi:ss\') And to_date(\'${end} \',\'yyyy-MM-dd hh24:mi:ss\')
Group By obi.item_code,obi.item_name,ood.ordered_by_dept,dd.dept_name ,obi.item_class, a.account_indicator
Union All
Select \'特种病\' as fl, obi.item_code,obi.item_name,ood.ordered_by_dept As dept_code ,dd.dept_name ,obi.item_class, a.account_indicator,
sum(obi.amount), sum(obi.costs) From outp_rcpt_master a,outp_bill_items obi,outp_order_desc ood,dept_dict dd
Where
a.rcpt_no = obi.rcpt_no
And obi.visit_date = ood.visit_date
And obi.visit_no = ood.visit_no
And ood.ordered_by_dept = dd.dept_code
And a.account_indicator = \'1\'
And obi.item_class In (\'A\',\'I\')
And a.charge_type In (\'SI超转\',\'海淀农合\',\'本院职工\',\'SI在职\',\'SI退休\',\'SI在职外\',\'SI在职残\',\'SI医保退\',\'SI退异地\',\'SI退职残\',\'SI退休残\',\'SI医退职\',\'SI退职异\',\'SI农民工\',\'SI老\',\'SI小\',\'新农合\',\'SI无业\')
And obi.visit_date
Between to_date(\'${start} \',\'yyyy-MM-dd hh24:mi:ss\') And to_date(\'${end}\',\'yyyy-MM-dd hh24:mi:ss\')
Group By obi.item_code,obi.item_name,ood.ordered_by_dept,dd.dept_name ,obi.item_class, a.account_indicator
Union All
Select \'住院\' as fl,
ibd.item_code ,ibd.item_name,dd.dept_code,dd.dept_name,ibd.item_class,0 As account_indicator,
Sum(ibd.amount),
Sum(ibd.costs)
From inp_bill_detail ibd,pat_visit pv,dept_dict dd
Where pv.patient_id = ibd.patient_id
And pv.visit_id = ibd.visit_id
And ibd.ordered_by = dd.dept_code
And ibd.item_class In (\'A\',\'I\')
And pv.charge_type In (\'SI超转\',\'海淀农合\',\'本院职工\',\'SI在职\',\'SI退休\',\'SI在职外\',\'SI在职残\',\'SI医保退\',\'SI退异地\',\'SI退职残\',\'SI退休残\',\'SI医退职\',\'SI退职异\',\'SI农民工\',\'SI老\',\'SI小\',\'新农合\',\'SI无业\')
And pv.discharge_date_time Between to_date(\'${start} \',\'yyyy-MM-dd hh24:mi:ss\') And to_date(\'${end}\',\'yyyy-MM-dd hh24:mi:ss\')
Group By ibd.item_code, ibd.item_name,dd.dept_code,dd.dept_name,ibd.item_class) a
where fl in (\'${fenlei}\')
and a.item_code=\'${code}\'
这是我的语句,相对于第一个报表,我就增加了最后一个条件,参数code