BigQuery SQL - COALESCE and IFNULL Functions

Raymond Tang Raymond Tang 0 2842 1.81 index 3/13/2021

Similar as other databases, BigQuery also supports a large number of SQL dialects. COALESCE and IFNULL functions are provided to deal with nullable values.

COALESCE

SELECT
  coalesce(NULL,
    1,
    2) as Col;

Output (in JSON format):

[
  {
    "Col": "1"
  }
]

IFNULL

SELECT
  ifnull(NULL,
    1) AS Col;

Output (in JSON format):

[
  {
    "Col": "1"
  }
]
bigquery gcp sql

Join the Discussion

View or add your thoughts below

Comments