# case¶

## Description¶

Return a matching result if the given condition is true. If no condition matches, return NULL. Conditions and results are evaluated in pairs in order of argument.

For a default or otherwise case, add the condition true and whatever value you want to the end of the cases.

any

## Domain¶

This is a scalar function (calculates a single output value for a single input row.)

## Usage¶

case( condition, result ... )


Argument

Type

Required

Multiple

condition

bool

Required

Can be multiple groups

result

any

Required

Can be multiple groups

## Examples¶

filter b=case(a=1, 'one', a=2, 'two', true, 'something else')


Filter to return rows where, if a is 1, b equals ‘one’, else if a is 2, b equals ‘two’, else b equals ‘something else’. The default case is supplied at the end, using the simple condition true.