select t1.*,t2,月份,t2.应发薪酬,t2.实发薪酬 from (select 姓名,职务,起始任期,终止任期 from 表A a where 起始任期=(select max(起始任期) from 表A b where a.姓名=b.姓名)) t1 left join 表B t2 on t1.姓名=t2.姓名
如有不懂请追问。
with page
as(select row_number() over(partition by 姓名 oder by 起始任期 desc) as row,* from a)
select *
from page inner join b
on page.姓名=b.姓名
where page.row=1