4D v16

case_expression

Home

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

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



Siehe auch 

arithmetic_expression
search_condition

 
EIGENSCHAFTEN 

Produkt: 4D
Thema: Syntax rules

 
GESCHICHTE 

 
ARTIKELVERWENDUNG

4D - SQL Reference ( 4D v16)