actually you want this i guessUPDATE t2SET t2.prm_proc=prc.prm_proc,t2.fnl_proc1=prc.fnl_proc1,t2.fnl_proc2=prc.fnl_proc2FROM smsdss.lcs_T2_reports_new t2 INNER JOIN (SELECT pt_id, MAX(CASE WHEN seq_no=1 THEN prc_code ELSE NULL END) AS prm_proc, MAX(CASE WHEN seq_no=2 THEN prc_code ELSE NULL END) AS fnl_proc1, MAX(CASE WHEN seq_no=3 THEN prc_code ELSE NULL END) AS fnl_proc2 FROM #temp_PC9_seq GROUP BY pt_id)prcON prc.pt_id=t2.pt_id