Hello MontyMagic,Perhaps something like this?;UPDATE cSET c.cdref = d.targetidFROM SLX_DTS.dbo.con cINNER JOIN( SELECT MAX(s.scoretotal) AS scoretotal, s.sourceid, s.targetid FROM SLX_DTS.dbo.con c JOIN SLX_DTS.dbo.c_score s ON c.recordid = s.sourceid GROUP BY s.sourceid, s.targetid WHERE s.scoretotal > 78 AND s.targetaccid IS NOT NULL) d ON d.sourceID = c.recordid
EDIT. I am not understanding the TOP 1(targetid) and TOP 1(targetaccid) for filtering. Could they be different if the ordering is the same (scoretotal) or is it simply an existence check? Perhaps the others fellows can provide a solution which does not rely on singleton but captures these requirements using sets. I am sure it can be reworked, but I do not understand the data well enough from this one statement. Not knowing the data, I cannot determine how aggregates might result, but Top 1 needs to be replaced with an aggregate which will allow set based rather than singleton scan for each record.If you could, would you provide some sample data for the 2 tables and an expected output? That would likely bring more solutions to the thread.HTH.