select * from employee
empid name
001 張三
002 李四
003 王五
select * from salary
empid month salary
001 1 100
001 2 200
001 3 300
002 1 200
002 2 400
003 3 500
select t3.name , t1.empid,t1.month,t2.salary from (
select empid,max(month) month from salary group by empid) t1
left join salary t2 on t2.empid = t1.empid and t2.month = t1.month
left join employee t3 on t3.empid = t2.empid