BigQuery SQL - COALESCE and IFNULL Functions

event 2021-03-13 visibility 2,747 comment 0 insights
more_vert
insights Stats
Raymond Raymond Code Snippets & Tips

Code snippets and tips for various programming languages/frameworks. All code examples are under MIT or Apache 2.0 license unless specified otherwise. 

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"
  }
]
More from Kontext
comment Comments
No comments yet.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts