Created
March 17, 2018 00:50
-
-
Save barsbek/47e951459afcc47e1e5ef0f7469610a2 to your computer and use it in GitHub Desktop.
postgresql: conditional return
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
select coalesce(col1, col2); -- return first col, which is not null | |
select nullif(val1, val2); -- return null if val1==val2, otherwise return val1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment