# 直接union all 开窗取最新 select employee_id as EMPLOYEE_ID , new_position as POSITION,update_dt as LAST_UPDATE_DT from ( select employee_id , update_dt, new_position , row_number()over(partition by employee_id order by update_dt desc,flg) as rn from ( select employee_id , update_dt, new_position,2 as flg from EMPLOYEE_UPDATE union all select employee_id , last_update_dt, position,1 as flg from EMPLOYEE_INFO )t )t where rn=1