「Postgresql入門」CASE WHENで複数の列から最大値を取得するサンプル
例1
SELECT CASE WHEN a < b THEN b
ELSE a END AS maxVal
FROM TEST_TBL;
例2
SELECT CASE WHEN CASE WHEN a < b THEN b
ELSE a END < c THEN c
ELSE CASE WHEN a < b THEN b
ELSE a END END AS maxVal
FROM TEST_TBL;