4D v14

case_expression

Home

 
4D v14
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

 
SEE ALSO 

arithmetic_expression
search_condition

 
ARTICLE USAGE

4D SQL Reference ( 4D v11 SQL Release 4 )
4D SQL Reference ( 4D v14)
4D SQL Reference ( 4D v12.1)
4D SQL Reference ( 4D v13.4)
4D SQL Reference ( 4D v14 R2)
4D SQL Reference ( 4D v14 R3)
4D SQL Reference ( 4D v14 R4)