'True if not null in SQL for Amazon Redshift
Is there a better way to get false when not null, and true when null? I cannot find a better way in the documentation.
SELECT
item_id as item_id
case some_field
when NULL
then FALSE else TRUE
end as is_active
FROM some_table
Solution 1:[1]
You can use the is null construct instead.
For example:
select *, f is null as y from t
Result:
f y
----- -----
0 false
1 false
null true
See running example at DB Fiddle.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | The Impaler |
