4D v13.4

case_expression

Home

 
4D v13.4
case_expression

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

Example  

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

 
PROPERTIES 

Product: 4D
Theme: Syntax rules

 
INDEX

Alphabetical list of commands

 
SEE ALSO 

arithmetic_expression
search_condition