version 11
case_expression
説明
case_expressionは式を選択する際、一つ以上の条件を適用するために使用します。
以下のように使用します:
CASE
WHEN search_condition THEN arithmetic_expression
...
WHEN search_condition THEN arithmetic_expression
[ELSE arithmetic_expression]
END
または
CASE arithmetic_expression
WHEN arithmetic_expression THEN arithmetic_expression
...
WHEN arithmetic_expression THEN arithmetic_expression
[ELSE arithmetic_expression]
END
例題
SELECT ROOM_NUMBER CASE ROOM_FLOOR WHEN 'Ground floor' THEN 0 WHEN 'First floor' THEN 1 WHEN 'Second floor' THEN 2 END AS FLOORS, SLEEPING_ROOM FROM T_ROOMS ORDER BY FLOORS, SLEEPING_ROOM
参照
arithmetic_expression, search_condition.