select b.UNIT_NAME as 医疗单位 ,c.DEPT_NAME as 科室, (select f.user_name from sys_user f where f.user_id = a.RESIDENT_ID ) as 主治医生, (select f.user_name from sys_user f where f.user_id = a.CLINIC_DOCTOR ) as 门诊医生, a.name as 姓名, a.INPATIENT_NO as 住院号, a.VISIT_ID as 就诊流水号, a.card_no as 卡号, a.age_text as 年龄, a.contacts_phone as 电话, d.name as 结算类型, a.bed_text as 床号, a.enter_time as 入院时间 from cis_inpatient a left join sys_unit b on a.unit_id = b.UNIT_ID left join sys_dept c on a.current_dept = c.DEPT_ID left join dict_account_type d on a.account_type = d.CODE where 1 =1 and a.unit_id in ('006002') and enter_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') and a.NOCASE_MARK=0 order by 医疗单位,科室,主治医生,姓名,床号 asc