Conditional Expressions

You use conditional expressions to create expressions that convert values.

The conditional expressions described in this section are building blocks for creating expressions that convert a value from one form to another.

Note:

• In `CASE` statements, `AND` has precedence over `OR`
• Strings must be in single quotes
Expression Example Description

`CASE` (If)

`CASE`

` WHEN score-par < 0 THEN 'Under Par'`

` WHEN score-par = 0 THEN 'Par'`

` WHEN score-par = 1 THEN 'Bogey'`

` WHEN score-par = 2 THEN 'Double Bogey'`

` ELSE 'Triple Bogey or Worse'`

` END`

Evaluates each `WHEN` condition and if satisfied, assigns the value in the corresponding `THEN` expression.

If none of the `WHEN` conditions are satisfied, it assigns the default value specified in the `ELSE` expression. If no `ELSE` expression is specified, the system automatically adds an `ELSE NULL`.

`CASE` (Switch)

`CASE Score-par`

` WHEN -5 THEN 'Birdie on Par 6'`

` WHEN -4 THEN 'Must be Tiger'`

` WHEN -3 THEN 'Three under par'`

` WHEN -2 THEN 'Two under par'`

` WHEN -1 THEN 'Birdie'`

` WHEN 0 THEN 'Par'`

` WHEN 1 THEN 'Bogey'`

` WHEN 2 THEN 'Double Bogey'`

` ELSE 'Triple Bogey or Worse'`

` END`

Also referred to as `CASE (Lookup)`. The value of the first expression is examined, then the `WHEN` expressions. If the first expression matches any `WHEN` expression, it assigns the value in the corresponding `THEN` expression.

If none of the `WHEN` expressions match, it assigns the default value specified in the `ELSE` expression. If no `ELSE` expression is specified, the system automatically adds an `ELSE NULL`.

If the first expression matches an expression in multiple `WHEN` clauses, only the expression following the first match is assigned.