# COALESCE

> COALESCE function in StackQL: return the first non-NULL argument from two or more, typically to substitute a default for a missing value.

Source: https://stackql.io/language-spec/functions/general/coalesce

Returns the first argument which is not `NULL` from a series of two or more arguments, can be used to substitute a default value for a `NULL` value.  

> The `COALESCE` function is equivalent to the `NVL` function in Oracle or the `IFNULL` function in MySQL.

See also:  
[[` SELECT `]](/language-spec/select) [[` IFNULL `]](/language-spec/functions/general/ifnull) [[` NULLIF `]](/language-spec/functions/general/nullif)

* * * 

## Syntax

```sql
SELECT COALESCE(expression1, expression2 [, ..]) FROM <multipartIdentifier>;
```

## Arguments

__*expression*__  
Two or more expressions of any data type which resolve to a `NULL` or non `NULL` value.

> If all of the *expression* arguments are `NULL`, the `COALESCE` function returns `NULL`.

## Return Value(s)

Returns the first non `NULL` value from the series of *expression* arguments.

* * *

## Examples

### Replace a `NULL` value with a default value

```sql
SELECT name, coalesce(website, cors, 'not hosting shared resources') AS website_or_cors_config
FROM google.storage.buckets where project = 'stackql';
```

For more information, see [https://www.sqlite.org/lang_corefunc.html#coalesce](https://www.sqlite.org/lang_corefunc.html#coalesce)
