Reputation: 2734
I would like to be able to SELECT
a NULL value in my SELECT
list so I can use it later in a UNION (for example). When I try SELECT NULL AS my_null_value FROM some_table
it gives me a syntax error. I can work around it by doing the following.
SELECT CASE WHEN 1=1 THEN NULL END AS my_null_value
FROM some_table
Is there a cleaner way to accomplish this? I feel like I have done this in less characters and in a simpler manner in the past than using a CASE
statement.
Upvotes: 0
Views: 525
Reputation: 2734
I ending up finding it.
A simpler (or more shorthand) way to accomplish this is to use the following:
SELECT NULLIF(0,0) AS my_null_value
FROM some_table
Upvotes: 0