SELECT *, (SELECT CLASS FROM TABLE AS t2 WHERE t2.C = t1.C AND t2.R = t1.R AND t2.STEP_ID = 8) AS STEP_2_CLASS FROM TABLE AS t1 WHERE (STEP_ID = 8 AND NOT EXISTS ( SELECT * FROM TABLE t2 WHERE t2.C= t1.C AND t2.R = t1.R AND t2.REVIEW_STEP_ID = 7 )) OR (STEP_ID = 7)