SELECT * FROM 表1 t1 JOIN (SELECT *, ROW_NUMBER() OVER(PARTITION BY 单据ID ORDER BY 处理时间 DESC) rn FROM 表2 ) t2 ON t1.单据ID = t2.单据ID AND t2.rn = 1
SELECT * FROM 表1 t1 JOIN (SELECT *, ROW_NUMBER() OVER(PARTITION BY 单据ID ORDER BY 处理时间 DESC) rn FROM 表2 ) t2 ON t1.单据ID = t2.单据ID AND t2.rn = 1