UPDATE table1 set field1= case when case when XX1='' or XX1 is null then 0 else cast(XX1 AS NUMERIC) end=(SELECT ISNULL(SUM(XX2),0) FROMXXX ) then 'Y' else 'N' end
UPDATE table1 set field1 = case when (case when xx1 is null then 0.0 when xx1='' then 0.0 else CAST(XX1 AS NUMERIC) end) = ( SELECT SUM(XX2) FROMXXX ) then 'Y' else 'N'
case when case when XX1='' or XX1 is null
then 0
else cast(XX1 AS NUMERIC)
end=(SELECT ISNULL(SUM(XX2),0) FROMXXX )
then 'Y'
else 'N'
end