select (select c.name from dict_mat_union@sj_dict c where c.code=w.code ) as 名称,
w.code as 材料代码,
(select p.unit_name from sys_unit p where p.unit_id =k.unit_id) as 医疗单位,
k.visit_id as 住院流水号,
(select u.name from cis_inpatient@sj_cis u where u.visit_id=k.visit_id) as 患者姓名,
(select s.user_name from sys_user s where s.user_id =k.DOCTOR_ID) as 开单医生,
k.BATCH_PRICE as 批发价,
k.EXPORT_PRICE as 零售价,
k.ITEM_UNIT as 单位,
k.AMOUNT as 金额,
k.CHARGE_TIME as 记账时间,
(select o.user_name from sys_user o where o.user_id =k.CHARGE_MAN) as 记账人,
k.CHARGE_MARK as 记账标志,
k.GIVE_TIME as 发放时间,
(select e.user_name from sys_user e where e.user_id =k.GIVE_MAN) as 发放人,
(select f.Dept_name from sys_dept f where f.dept_id=k.PAT_DEPT and f.Unit_Id =k.unit_id) as 患者所在科室,
k.BATCH_NO as 批号,
k.PRACTICE_DT as 执行时间,
(select e.user_name from sys_user e where e.user_id =k.PRACTICE_OPERATOR) as 执行人
from fee_in_mater k
left join dict_mat_union@sj_dict w on w.code=k.mater_code and w.mat_type='3'
where w.code is not null and k.visit_id !='006002-7149'
and k.unit_id='006002'
and GIVE_TIME between to_date('2021-09-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss') and to_date('2021-09-30 23:59:59', 'yyyy-mm-dd hh24:mi:ss')