CHAR: from Tableau to SQL

Returns the character for a Unicode code point. Below, 8 sample rows go through the calculation and through the SQL, and both return the same numbers.

Calculated field

CHAR([quantity])

Sample data

labelquantityamountflag
cedar cedar 6512.8True
ORCHID-west66-7.6False
maple-east670null
willow north6825.3True
birch-birch694.9False
pine/south70-1.2null
ash719True
nullnullnullnull

The same calculation as SQL

SELECT chr(quantity::integer) AS result FROM input

Runs the example above.

Result

result
A
B
C
D
E
F
G
null

Same rows from the calculation and from the SQL in DuckDB.

Where a naive translation goes wrong

  • Replacing CHAR with quantity::varchar changes the shown values or null handling.

    Naive SQL

    SELECT quantity::varchar AS result FROM input
    result
    65
    66
    67
    68
    69
    70
    71
    null

    Matches the calculation

    SELECT chr(quantity::integer) AS result FROM input
    result
    A
    B
    C
    D
    E
    F
    G
    null

Signature

CHAR(integer)