Created
July 26, 2018 11:34
-
-
Save renatocron/f1718568904ed70bc32aefe6258cd266 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
with orig as ( | |
select 'original value'::text as foo limit 1 | |
), | |
orig_if_not as ( | |
select 'the value if first query returns no rows'::text as foo | |
) | |
select coalesce(a.foo, b.foo) as the_foo | |
from orig a | |
right join orig_if_not b on (a.foo is not null) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment