SELECTtt.int _ interpreting_data_id, tt. dt_report_date, tn. str_norm_number, tnt. str_norm_type_name, tt.int _ whether, tt. str_value, tt. str_detection_result, tt. str_remark, tn. str_name, tn.int _ response_type, tt. str_device_name, tt. str_ip, tt. db_name, tn. str_codeF... mysql
SELECT tt.int _ interpreting_data_id, tt. dt_report_date, tn. str_norm_number, tnt. str_norm_type_name, tt.int _ whether, tt. str_value, tt. str_detection_result, tt. str_remark, tn. str_name, tn.int _ response_type, tt. str_device_name, tt. str_ip, tt. db_name, tn. str_code
FROM t_norm tn LEFT JOIN
(
SELECT Region _ code, tid1.int _ partition, region _ report_date, tid1.str _ norm_type_name, tid1.int _ whether, tid1.str _ value, tid1.str _ partition, tid1.str _ remark, tid1.str _ device_name, tid1.str _ ip, tid1.db _ name, tid1.str _ norm_number FROM t_interpreting_data tid1,
(
SELECT str_code, comment, str_norm_type_name, int_whether, str_value, comment, str_remark, str_device_name, str_ip, db_name, str_norm_number, max (dt_report_date) max_date FROM comment WHERE 1 = 1
AND str_property_id = 'windows 7_852'
AND STR_TO_DATE (dt_report_date, '% Y-% m-% d') = '2017-06-05'
Group by str_norm_number, db_name
) Tid2
WHERE tid1.dt _ report_date = tid2.max _ date
Group by tid1.str _ norm_number, tid1.db _ name
Order by tid1.dt _ report_date DESC
) Tt on tn. str_norm_number = tt. str_norm_number
Left join t_norm_type tnt ON tn.int _ norm_type_id = tnt.int _ norm_type_id
WHERE tn. str_code IN (SELECT str_code FROM t_interpreting_data WHERE str_property_id = 'windows 7_852 'group by str_code)
Order by tt. str_norm_number DESC
1. use the t_norm table as the standard
2. query the latest records of the same type in the t_interpreting_data table, and group the records according to db_name.