Documentation

    CASE

    Choose a result using one or more conditions.

    Try an expression

    In Formula, enter the expression and set Output type to VARCHAR.

    Example input

    1. Row 1amount = 20
    2. Row 2amount = 120
    3. Row 3amount = NULL

    Expression

    CASE WHEN amount > 100 THEN 'high' ELSE 'low' END

    Result

    Row 1: 'low'
    Row 2: 'high'
    Row 3: 'low'

    NULL means the value is missing.

    Arguments and types

    CASE WHEN condition THEN result ELSE fallback END

    The result type can depend on the input types. See DuckDB for the full argument rules.

    Browse conditions & missing valuesDuckDB documentation

    Function metadata from DuckDB, used under the MIT license.