With this query:
SELECT Date, Types, MAX(Report_ID) Report_ID
FROM t2
GROUP BY Date, Types
you get the max Report_ID
for each Date
and Types
Join it to t1
:
SELECT t2.Date, t2.Types, t1.Name, t1.Value, t1.Report_ID
FROM t1
INNER JOIN (
SELECT Date, Types, MAX(Report_ID) Report_ID
FROM t2
GROUP BY Date, Types
) t2 ON t2.Report_ID = t1.Report_ID
See the demo.
Results:
Date |
Types |
Name |
Value |
Report_ID |
2020-01-01 |
Type 1 |
Name 2 |
Value 2 |
2 |
2020-01-01 |
Type 3 |
Name 3 |
Value 3 |
3 |
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…