可以使用子查询的方式将高值耗材费和低值耗材费加入到上面的SQL中,具体如下:

select c.hos_name 院区, d.fee_stat_name 费用类别, sum(t.tot_cost) 费用金额, (select sum(b.tot_cost) from fin_ipb_balancehead a,fin_ipb_itemlist b,fin_com_undruginfo u,fin_com_feecodestat c,com_department d where a.inpatient_no=t.inpatient_no and b.fee_code='013' and a.invoice_no=b.invoice_no and a.trans_type=b.trans_type and a.inpatient_no=b.inpatient_no and b.ITEM_CODE=u.item_code and b.fee_code=c.fee_code and c.report_code='ZY01' and b.recipe_deptcode=d.dept_code and u.UNIT_PRICE >= 3000 and u.IS_IMPLANTS = '1') 植入高值耗材费, (select sum(b.tot_cost) from fin_ipb_balancehead a,fin_ipb_itemlist b,fin_com_undruginfo u,fin_com_feecodestat c,com_department d where a.inpatient_no=t.inpatient_no and b.fee_code='013' and a.invoice_no=b.invoice_no and a.trans_type=b.trans_type and a.inpatient_no=b.inpatient_no and b.ITEM_CODE=u.item_code and b.fee_code=c.fee_code and c.report_code='ZY01' and b.recipe_deptcode=d.dept_code and u.UNIT_PRICE < 3000 and u.IS_IMPLANTS = '1') 植入低值耗材费

from fin_ipb_feeinfo t,fin_ipr_inmaininfo b,com_hospitalinfo c,fin_com_feecodestat d where t.balance_state='1' AND t.inpatient_no=b.inpatient_no and t.fee_date<to_date('2023-3-1,00:00:00', 'yyyy-mm-dd,hh24:mi:ss') and b.balance_date BETWEEN to_date('2023-3-1,00:00:00', 'yyyy-mm-dd,hh24:mi:ss') and to_date('2023-3-20,23:59:59', 'yyyy-mm-dd,hh24:mi:ss') AND b.in_state in('O') and c.hos_code=b.hospital_didt and t.fee_code=d.fee_code and d.report_code='ZY01' --and (c.hos_code=[Condition-院区] or [Condition-院区]='all') GROUP BY c.hos_name,d.fee_stat_name

---高低值区分select chos_name 院区dfee_stat_name 费用类别sumttot_cost 费用金额from fin_ipb_feeinfo tfin_ipr_inmaininfo bcom_hospitalinfo cfin_com_feecodestat dwhere tbalance_state=1AND tinpatient_no=binpatient_noand

原文地址: https://www.cveoy.top/t/topic/fh2o 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录