select concat(t.customer_id, "-", t.record_id), t.* from
(
select qpi.customer_id, qpi.record_id, qpi.patient_guid, qpi.rule_id, qpi.item_id, qpi.item, qpi.disease_id, qpi.inpatient_department,
qpi.doctor_name, max(qpi.result)
from qc_patient_item as qpi
join yd_patient_11_basic_info as detail
on concat(qpi.customer_id, "-", qpi.record_id)=detail.uuid
where qpi.item="ESR检测"
GROUP BY qpi.record_id
having max(qpi.result)>0
) as t
where t.record_id not in (
select distinct qpi.record_id
from qc_patient_item as qpi
join yd_patient_11_basic_info as detail
on concat(qpi.customer_id, "-", qpi.record_id)=detail.uuid
where qpi.item="ESR检测" and qpi.result=0
)
网友评论