Count the data of yesterday and today, and first find out the Unit by unit grouping, and then perform external association with the subquery in the Java code select * from -- Query all the institutions in the organization table (select distinct dc. district_code, dc. id unit_id, dc. unit_name FROM pc_base_unit dc) o left join -- count the data of the day before yesterday (SELECT dc. unit_id, SUM (dc. OUTPATIENT_REGISTER) Outpatient registration, SUM (dc. RECIPEL_DETAIL) Outpatient prescription details, SUM (dc. INHOSPITAL_REGISTER) Hospitalization registration, SUM (dc. INHOSPITAL_DETAIL) Hospital details, SUM (dc. BASEINFO) Basic information of the file FROM pc_data_datacleancollect dc WHERE to_char (dc. CLEAN_TIME, 'yyyy-mm-dd') = to_char (SYSDATE-2, 'yyyy-mm-dd') group by dc. unit_id) a ON o. unit_id =. unit_id left join (-- calculate the data of yesterday's SELECT dc. unit_id, SUM (dc. OUTPATIENT_REGISTER) Outpatient registration, SUM (dc. RECIPEL_DETAIL) Outpatient prescription details, SUM (dc. INHOSPITAL_REGISTER) Hospitalization registration, SUM (dc. INHOSPITAL_DETAIL) Hospital details, SUM (dc. BASEINFO) Basic information of the file FROM pc_data_datacleancollect dc WHERE to_char (dc. CLEAN_TIME, 'yyyy-mm-dd') = to_char (SYSDATE-1, 'yyyy-mm-dd') group by dc. unit_id) B ON o. unit_id = B. unit_id left join (-- calculate the data of today's SELECT dc. unit_id, SUM (dc. OUTPATIENT_REGISTER) Outpatient registration, SUM (dc. RECIPEL_DETAIL) Outpatient prescription details, SUM (dc. INHOSPITAL_REGISTER) Hospitalization registration, SUM (dc. INHOSPITAL_DETAIL) Hospital details, SUM (dc. BASEINFO) Basic information of the file FROM pc_data_datacleancollect dc WHERE to_char (dc. CLEAN_TIME, 'yyyy-mm-dd') = to_char (SYSDATE, 'yyyy-mm-dd') group by dc. unit_id) c ON o. unit_id = c. unit_id