update spl
set spl.stageApprovedDate = hist.changeDateTime
from tbl_SPL_Opportunities spl
inner join (
select opportunityId, newStageId, max( changeDateTime ) changeDateTime
from tbl_SPL_Opportunity_StageChanges
group by opportunityId, newStageId
) hist
on hist.opportunityId = spl.opportunityId
and hist.newStageId = spl.stageId
where spl.ownerId =
and spl.ownerType =
includeCSS();
includeCSS();
includeCSS();
#_x#