Dies ist die alte 4D Dokumentations-Website. Die neue und aktualisierte Dokumentation finden Sie unter developer.4d.com |
||||||||||||||
|
4D v20
case_expression
|
case_expression |
||
A case_expression is used to apply one or more conditions when selecting an expression.
They can be used as follows, for example:
CASE
WHEN search_condition THEN arithmetic_expression
...
WHEN search_condition THEN arithmetic_expression
[ELSE arithmetic_expression]
END
Or:
CASE arithmetic_expression
WHEN arithmetic_expression THEN arithmetic_expression
...
WHEN arithmetic_expression THEN arithmetic_expression
[ELSE arithmetic_expression]
END
This example selects records from the ROOM_NUMBER column according to the value of the ROOM_FLOOR column:
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
Produkt: 4D
Thema: Syntax rules
4D - SQL Reference ( 4D v20)