Skip to content

Latest commit

 

History

History
28 lines (22 loc) · 644 Bytes

replace-null.md

File metadata and controls

28 lines (22 loc) · 644 Bytes

Replace NULLs

Explore this snippet here.

Description

An essential part of cleaning a new data source is deciding how to treat NULL values. The Snowflake function IFNULL can help with replacing NULL values with something else:

with data as (
  select * from (values
    (1,    'one'),
    (null, 'two'),
    (3,    null)
  ) as data (num, str)
)

select
  ifnull(num, -1) num,
  ifnull(str, 'I AM NULL') str
from data
NUM STR
1 a
-1 b
3 I AM NULL