

# Null Functions
<a name="sql-reference-null-functions"></a>

The topics in this section describe the null functions for Amazon Kinesis Data Analytics streaming SQL.

**Topics**
+ [COALESCE](sql-reference-coalesce.md)
+ [NULLIF](sql-reference-nullif.md)

# COALESCE
<a name="sql-reference-coalesce"></a>

```
COALESCE (
      <value-expression>
      {,<value-expression>}... )
```

The COALESCE function takes a list of expressions (all of which must be of the same type) and returns the first non-null argument from the list. If all of the expressions are null, COALESCE returns null.

## Examples
<a name="sql-reference-coalesce-examples"></a>


| Expression | Result | 
| --- | --- | 
|  COALESCE('chair')  |  chair  | 
|  COALESCE('chair', null, 'sofa')  |  chair  | 
|  COALESCE(null, null, 'sofa')  |  sofa  | 
|  COALESCE(null, 2, 5)  |  2  | 

# NULLIF
<a name="sql-reference-nullif"></a>

```
NULLIF ( <value-expression>, <value-expression> )
```

Returns null if the two input arguments are equal, otherwise returns the first value. Both arguments must be of comparable type, or an exception is raised.

## Examples
<a name="sql-reference-nullif-examples"></a>


| Function | Result | 
| --- | --- | 
|  NULLIF(4,2)  |  4  | 
|  NULLIF(4,4)  |  <null>  | 
|  NULLIF('amy','fred')  |  amy  | 
|  NULLIF('amy', cast(null as varchar(3)))  |  amy  | 
|  NULLIF(cast(null as varchar(3)),'fred')  |  <null>  | 