1
select * from DOCS_NORMAL_REPORT_REC t left join v_his_pats_discharge d on t.patient_id=d.patient_id
2
select t.patient_id,
d.patient_name,
v.bed_no,
COUNT(t.PATIENT_ID) AS TOTAL_STATISTICS
from DOCS_NORMAL_REPORT_REC t
left join v_his_pats_discharge v
on t.patient_id = v.patient_id
left join DOCS_PATIENT_CARD_REC d
on t.patient_id = d.patient_id
where t.update_time>v.leave_time
group by t.patient_id,d.patient_name, v.bed_no
3
select p.patient_id,
v.patient_name,
v.bed_no,
count(t.patient_id) as total_statistics
from v_his_pats_discharge p
left join v_his_pats_discharge v on p.patient_id = v.patient_id
left join docs_normal_report_rec t on p.patient_id=t.patient_id
left join docs_risk_report_rec r on p.patient_id=r.patient_id
left join DOCS_EVAL_REPORT_REC e on p.patient_id=e.patient_id
left join DOCS_VITAL_SIGNS_REC s on p.patient_id=s.patient_id
left join DOCS_REPORT_REC re on p.patient_id=re.patient_id
where (t.update_time>v.leave_time or r.update_time>v.leave_time or
e.update_time>v.leave_time or re.update_time>v.leave_time or s.update_time>v.leave_time)
--and ( v.leave_time, t.update_time, e.update_time ,r.update_time,re.update_time)
--BETWEEN
-- TO_DATE(:startTime, 'YYYY/MM/DD HH24:MI:SS') AND
-- TO_DATE(:endTime, 'YYYY/MM/DD HH24:MI:SS'))
group by p.patient_id,v.patient_name, v.bed_no
4 原来的
SELECT PATIENT_ID,
VISIT_ID,
BED_NO,
PATIENT_NAME,
CREATOR_UNIT,
COUNT(PATIENT_ID) AS TOTAL_STATISTICS
FROM (SELECT T.PATIENT_ID,
T.VISIT_ID,
T.PATIENT_NAME,
T.BED_NO,
T.CREATOR_UNIT
FROM DOCS_VITAL_SIGNS_REC T
WHERE T.DISCHARGE_MODIFIED = '1'
AND T.CREATOR_UNIT = :deptcode
AND T.LAST_OPER_DATE BETWEEN
TO_DATE(:startTime, 'YYYY/MM/DD HH24:MI:SS') AND
TO_DATE(:endTime, 'YYYY/MM/DD HH24:MI:SS'))
GROUP BY PATIENT_NAME, BED_NO, PATIENT_ID, VISIT_ID, CREATOR_UNIT
ORDER BY LENGTH(BED_NO), BED_NO