SELECT bid patient_id bbracelet_no bpatient_name bgender bage_unit bagentdinjury_levelbwounded_type aupdater creator aupdate_date create_dateabatch FROM nr_first_check_registratio
The query selects the following columns:
- b.id as patient_id
- b.bracelet_no
- b.patient_name
- b.gender
- b.age_unit
- b.age
- ntd.injury_level
- b.wounded_type
- a.updater as creator
- a.update_date as create_date
- a.batch
The data is retrieved from the tables nr_first_check_registration (aliased as b), nr_decontamination (aliased as a), and nr_triage_data (aliased as ntd).
The query uses an inner join between nr_first_check_registration and a subquery that retrieves the latest updater and update_date for each patient_id in nr_decontamination. The join condition is b.id = a.patient_id.
It also performs a left join between nr_first_check_registration and nr_triage_data on the patient_id column.
The query includes several conditions in the WHERE clause:
- b.deleted = 0: Only select rows where the deleted column in nr_first_check_registration is 0.
- b.task_id = 1686624740401336322: Only select rows where the task_id column in nr_first_check_registration is equal to 1686624740401336322.
- ntd.deleted = 0: Only select rows where the deleted column in nr_triage_data is 0.
- b.bracelet_no = 987987: Only select rows where the bracelet_no column in nr_first_check_registration is equal to 987987.
The result is grouped by a.batch and ordered by a.update_date in descending order
原文地址: http://www.cveoy.top/t/topic/iZiV 著作权归作者所有。请勿转载和采集!