Hi @Malam Malam ,
Please refer below query and define the order by yourself according to your requirement:
;with cte as (
select *,ROW_NUMBER() OVER (PARTITION BY Custnumber
order by Custnumber,custaddress --define your order column here
set a.CustCity =c.CustCity
from TableA a
inner join TableB b on a.CustNumber=b.CustNumber
inner join cte c on b.CustID=c.CustNumber
If the answer is helpful, please click "Accept Answer" and upvote it.
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.