﻿---
title: ES|QL COALESCE function
description: 
url: https://www.elastic.co/elastic/docs-builder/docs/2455/reference/query-languages/esql/functions-operators/conditional-functions-and-expressions/coalesce
products:
  - Elasticsearch
---

# ES|QL COALESCE function
## Syntax

![Embedded](https://www.elastic.co/elastic/docs-builder/docs/2455/reference/query-languages/esql/images/functions/coalesce.svg)


## Parameters

<definitions>
  <definition term="first">
    Expression to evaluate.
  </definition>
  <definition term="rest">
    Other expression to evaluate.
  </definition>
</definitions>


## Description

Returns the first of its arguments that is not null. If all arguments are null, it returns `null`.

## Supported types


| first                                                                           | rest                                                                            | result                |
|---------------------------------------------------------------------------------|---------------------------------------------------------------------------------|-----------------------|
| boolean                                                                         | boolean                                                                         | boolean               |
| boolean                                                                         |                                                                                 | boolean               |
| cartesian_point                                                                 | cartesian_point                                                                 | cartesian_point       |
| cartesian_shape                                                                 | cartesian_shape                                                                 | cartesian_shape       |
| date                                                                            | date                                                                            | date                  |
| date_nanos                                                                      | date_nanos                                                                      | date_nanos            |
| dense_vector                                                                    | dense_vector                                                                    | dense_vector          |
| exponential_histogram <applies-to>Elastic Stack: Preview since 9.3</applies-to> | exponential_histogram <applies-to>Elastic Stack: Preview since 9.3</applies-to> | exponential_histogram |
| geo_point                                                                       | geo_point                                                                       | geo_point             |
| geo_shape                                                                       | geo_shape                                                                       | geo_shape             |
| geohash                                                                         | geohash                                                                         | geohash               |
| geohex                                                                          | geohex                                                                          | geohex                |
| geotile                                                                         | geotile                                                                         | geotile               |
| histogram <applies-to>Elastic Stack: Preview since 9.3</applies-to>             | histogram <applies-to>Elastic Stack: Preview since 9.3</applies-to>             | histogram             |
| integer                                                                         | integer                                                                         | integer               |
| integer                                                                         |                                                                                 | integer               |
| ip                                                                              | ip                                                                              | ip                    |
| keyword                                                                         | keyword                                                                         | keyword               |
| keyword                                                                         |                                                                                 | keyword               |
| long                                                                            | long                                                                            | long                  |
| long                                                                            |                                                                                 | long                  |
| tdigest <applies-to>Elastic Stack: Preview since 9.3</applies-to>               | tdigest <applies-to>Elastic Stack: Preview since 9.3</applies-to>               | tdigest               |
| text                                                                            | text                                                                            | keyword               |
| text                                                                            |                                                                                 | keyword               |
| version                                                                         | version                                                                         | version               |


## Example

```esql
ROW a=null, b="b"
| EVAL COALESCE(a, b)
```


| a:null | b:keyword | COALESCE(a, b):keyword |
|--------|-----------|------------------------|
| null   | b         | b                      |