coalesce

Returns the first non-null value in the argument list. Like a CASE expression, arguments are only evaluated if necessary.

Examples:

examples.sql
CREATE TABLE tbl as VALUES ('1', null), ('2', '2'), (null, '3');
SELECT 
    COALESCE(column1, column2) as value
FROM tbl;
 -- value '('1', '2', '3')'

Supported Signatures

function coalesce($1, ...) returns $1

🔗 Official Documentation

if

Evaluates expression parameter and returns second if condition is true, otherwise null is returned and true_value is not evaluated.

Examples:

examples.sql
SELECT IF(2 < 1, 'HIGHER') AS value; -- value 'NULL'

Supported Signatures

function if(boolean, $1) returns $1
function if(boolean, $1, $1) returns $1

🔗 Official Documentation

nullif

Returns null if value1 equals value2, otherwise returns value1.

Examples:

examples.sql
SELECT nullif(1, 1) AS value; -- value 'NULL'
SELECT nullif(2, 1) AS value; -- value '2'

Supported Signatures

function nullif($1, $1) returns $1

🔗 Official Documentation

try

Evaluate an expression and handle certain types of errors by returning NULL.

Supported Signatures

function try($1) returns $1

🔗 Official Documentation