> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sdf.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Conditional Functions

## `coalesce`

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

*Examples:*

```sql examples.sql theme={null}
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*

```sql theme={null}
function coalesce($1, ...) returns $1
```

[🔗 Official Documentation](https://trino.io/docs/current/functions/conditional.html#coalesce-function)

## `if`

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

*Examples:*

```sql examples.sql theme={null}
SELECT IF(2 > 1, 'HIGHER', 'LOWER') AS value; -- value 'HIGHER'
```

*Supported Signatures*

```sql theme={null}
function if(boolean, $1, $1) returns $1
```

[🔗 Official Documentation](https://trino.io/docs/current/functions/conditional.html#if-expression)

## `nullif`

Returns null if value1 equals value2, otherwise returns value1.

*Examples:*

```sql examples.sql theme={null}
SELECT nullif(1, 1) AS value; -- value 'NULL'
SELECT nullif(2, 1) AS value; -- value '2'
```

*Supported Signatures*

```sql theme={null}
function nullif($1, $1) returns $1
```

[🔗 Official Documentation](https://trino.io/docs/current/functions/conditional.html#nullif-function)
