lili_tiger
lili_tiger

Reputation: 3

Replace empty/NULL result by "FALSE" in the result of SELECT

I need to know if it is possible to replace the result of a SELECT by the string "FALSE", when a value returned empty or null? Thank you

Upvotes: 0

Views: 371

Answers (3)

Venkata Muttineni
Venkata Muttineni

Reputation: 86

SELECT CASE WHEN COLUMN IS NULL OR COLUMN '' THEN 'FALSE' ELSE COLUMN END FROM TABLE_NAME

Upvotes: 0

Morcous Wahba
Morcous Wahba

Reputation: 49

You're looking for COALESCE.

SELECT COALESCE(COL_NAME, 'False') AS COL_NAME FROM table_name

Upvotes: 0

Zaynul Abadin Tuhin
Zaynul Abadin Tuhin

Reputation: 31991

you can use case when

select case when COL_NAME is null  OR LENGTH(TRIM (COL_NAME)) = 0 then 'False' 
           else COL_NAME end
       from table_name

Upvotes: 1

Related Questions