UPDATE t SET t.Code = md.Code, t.GPOName = md.GPONam, t.TotalMO = md.TotalMO FROM tempDailyUPD JOIN ( select distinct(masterdata.gpo_id) as Code, gpo.name as GPOName, count(masterdata.mno) as TotalMO from masterdata, gpo where masterdata.gpo_id = gpo.gpo_id group by masterdata.gpo_id, gpo.name ) md ON t.[Your Destination JOIN Column] = md..[Your Source JOIN Column]