

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# COALESCE 表達式
<a name="coalesce-function"></a>

COALESCE 表達式會傳回清單中不是 null 的第一個表達式的值。如果所有表達式都是 Null，則結果為 Null。找到非 Null 值時，就不會評估清單中剩餘的表達式。

如果您想在慣用值遺失或為 Null 時傳回備用值，這種表達式很有用。例如，查詢可能傳回三個電話號碼的其中之一 (依序為行動、住家或公司)，視資料表中最先找到何者而定 (不是 Null)。

## 語法
<a name="coalesce-function-syntax"></a>

```
COALESCE (expression, expression, ... )
```

## 範例
<a name="coalesce-function-examples"></a>

將COALESCE表達式套用至兩個資料欄。

```
select coalesce(start_date, end_date)
from datetable
order by 1;
```

NVL 表達式的預設資料欄名稱為 COALESCE。下列查詢會傳回相同的結果。

```
select coalesce(start_date, end_date) from datetable order by 1;
```