Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 349
knozawa Avatar asked Oct 18 '25 13:10

knozawa


1 Answers

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

SELECT ID, COALESCE(Name, 'Not Defined') AS Name
FROM tab
like image 134
Lukasz Szozda Avatar answered Oct 22 '25 07:10

Lukasz Szozda



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!