update #Sample_2019 set Date_Of_Service = a.DOS
from ( Select Unique_ID, MIN(DOS) as DOS
From #Sample_2019 a
inner join [dbo].[MainTable] b on Unique_ID1 = b.Unique_ID
group by Unique_ID
) a
update #Sample_2019 set Date_Of_Service = a.DOS
from ( Select Unique_ID, MIN(DOS) as DOS
From #Sample_2019 a
inner join [dbo].[MainTable] b on Unique_ID1 = b.Unique_ID
group by Unique_ID
) a
update #Sample_2019 set Date_Of_Service = a.DOS
from #Sample_2019 targetTable
JOIN ( Select Unique_ID, MIN(DOS) as DOS
From #Sample_2019 a
inner join [dbo].[MainTable] b on Unique_ID1 = b.Unique_ID
group by Unique_ID
) a ON targetable.Unique_ID = a.Unique_ID
17 People are following this question.