Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
COALESCE
使用 COALESCE 將空值替換為更有意義的預設值。
用法示範
COALESCE(Field1, Field2, Field3)
語法
COALESCE( field_expression [, field_expression,...])
參數
field_expression - 欄位或運算式。所有 field_expressions 都必須是相同類型。
範例
假設您想追蹤一場賽事中多場賽次的多位選手,選手可能會因為各種原因而沒有出賽。您想建立 First_Time 欄位,其中包含每位賽車手的第一個結果。
以下為比賽資料。
| Racer |
Heat1 |
Heat2 |
Heat3 |
| Racer X |
|
38.22 |
37.61 |
| Racer Y |
41.33 |
|
38.04 |
| Racer Z |
39.27 |
39.04 |
38.85 |
在「First_Time」欄位中使用下列公式,從「Heat」欄位取得第一個非空值:
COALESCE(Heat1, Heat2, Heat3)
結果:
| Racer |
Heat1 |
Heat2 |
Heat3 |
First_Time |
| Racer X |
null |
38.22 |
37.61 |
38.22 |
| Racer Y |
41.33 |
null |
38.04 |
41.33 |
| Racer Z |
39.27 |
39.04 |
38.85 |
39.27 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2026-05-28 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2026-05-28 (世界標準時間)。"],[],[]]