Skip to content

Instantly share code, notes, and snippets.

@shahnazmshariff
Last active June 9, 2020 21:30
Show Gist options
  • Save shahnazmshariff/b75d7c372b9989cfbfc2e3d163917bab to your computer and use it in GitHub Desktop.
Save shahnazmshariff/b75d7c372b9989cfbfc2e3d163917bab to your computer and use it in GitHub Desktop.
SQL blog example 1
SELECT SUM(qty) FILTER (where type = 'domestic' and item = 'desk') AS desk_from_domestic,
SUM(qty) FILTER (where type = 'domestic' and item = 'bat') as bat_from_domestic
FROM purchases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment