---
title: nanvl function
description: Learn the syntax of the nanvl function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/nanvl
---

# `nanvl` function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime

Returns `expr1` if it's not `NaN`, or `expr2` otherwise.

## Syntax

```
nanvl(expr1, expr2)
```

## Arguments

* `expr1`: An expression that evaluates to a numeric.
* `expr2`: An expression that evaluates to a numeric.

## Returns

A `DOUBLE`.

## Examples

```sql
> SELECT nanvl(cast('NaN' AS DOUBLE), 123);
 123.0
```

## Related functions

* [`coalesce` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/coalesce.md)
