Created
May 8, 2019 21:25
-
-
Save jjn1056/d0a962d42262e21317326ec1e7afe7f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
catme=> select | |
catme-> CASE | |
catme-> WHEN COALESCE(name, school) = '' THEN 'EMPTY STRING' | |
catme-> WHEN COALESCE(name, school) = NULL THEN 'NULL1' | |
catme-> WHEN COALESCE(name, school) IS NULL THEN 'NULL2' | |
catme-> ELSE COALESCE(name, school) | |
catme-> END as institution | |
catme-> from ( | |
catme(> SELECT 'name' as name, 'school' as school | |
catme(> UNION ALL | |
catme(> SELECT NULL as name, NULL as school | |
catme(> UNION ALL | |
catme(> SELECT '' as name, '' as school | |
catme(> UNION ALL | |
catme(> SELECT '1' as name, '' as school | |
catme(> UNION ALL | |
catme(> SELECT '2' as name, NULL as school | |
catme(> UNION ALL | |
catme(> SELECT '' as name, '3' as school | |
catme(> UNION ALL | |
catme(> SELECT NULL as name, '4' as school | |
catme(> ) as stuff(name, school); | |
institution | |
-------------- | |
name | |
NULL2 | |
EMPTY STRING | |
1 | |
2 | |
EMPTY STRING | |
4 | |
(7 rows) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment