Hi @T.Zacks
Or you can try this query.
;with T1 as(
select * from table1
union all
select * from table2
),T2 as(
select *,row_number()over(partition by ID order by ModDate desc) as num from T1)
select ID,Name,Salary,ModDate from T2 where num = 1;
Best regards,
Percy Tang
If the answer is the right solution, please click "Accept Answer". If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.