I have an inherited an incredibly ugly SQL statement INSERT INTO tmptbl (KEY, ERROR)
SELECT KEY, MIN(ERROR) AS ERROR
FROM (<incredibly ugly statement>) AS Q
GROUP BY KEY
that returns the lowest error state. Of course, there is now a new error check that needs to return, prior to other checks...