knozawa
knozawa

Reputation: 283

How to replace NULL to specific string in snowflake (SQL)

Does anyone know how to replace NULL to specific string in snowflake (SQL)?

Before

ID Name
1 Apple
2 NULL
3 NULL

After

ID Name
1 Apple
2 Not Defined
3 Not Defined

I would like to replace NULL with Not Defined.

Upvotes: 4

Views: 10568

Answers (2)

awills
awills

Reputation: 1

UPDATE "DB"."SCHEMA"."TABLE"

SET "Name" =  ('Not Defined')
WHERE "Name" IS NULL;

Upvotes: 0

Lukasz Szozda
Lukasz Szozda

Reputation: 175586

NULL value could be replaced using the following functions: IFNULL/NVL/COALESCE:

SELECT ID, COALESCE(Name, 'Not Defined') AS Name
FROM tab

Upvotes: 10

Related Questions