Skip to content

Instantly share code, notes, and snippets.

@barsbek
Created March 17, 2018 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barsbek/47e951459afcc47e1e5ef0f7469610a2 to your computer and use it in GitHub Desktop.
Save barsbek/47e951459afcc47e1e5ef0f7469610a2 to your computer and use it in GitHub Desktop.
postgresql: conditional return
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