, :
SELECT
dt.*,
CASE maxscore
WHEN score1 THEN Greatest(score2, score3, score4, score5)
WHEN score2 THEN Greatest(score1, score3, score4, score5)
WHEN score3 THEN Greatest(score1, score2, score4, score5)
WHEN score4 THEN Greatest(score1, score2, score3, score5)
ELSE Greatest(score1, score2, score3, score4)
END
FROM
(
SELECT t.*,
Greatest(Score1,Score2,Score3,Score4,Score5) AS maxscore
FROM tab t
) dt
@vkp @mathguy Derived Table/Inline View:
SELECT
t.*,
Greatest(Score1,Score2,Score3,Score4,Score5) as Highest1_value,
CASE Greatest(Score1,Score2,Score3,Score4,Score5)
WHEN score1 THEN Greatest( score2,score3,score4,score5)
WHEN score2 THEN Greatest(score1, score3,score4,score5)
WHEN score3 THEN Greatest(score1,score2, score4,score5)
WHEN score4 THEN Greatest(score1,score2,score3, score5)
ELSE Greatest( score1,score2,score3,score4)
END as Highest2_value
FROM tab t