Skip to content

Instantly share code, notes, and snippets.

@benmmurphy
Created September 8, 2016 09:33
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 benmmurphy/eadd9edf5e77e7c65e868891d40667ac to your computer and use it in GitHub Desktop.
Save benmmurphy/eadd9edf5e77e7c65e868891d40667ac to your computer and use it in GitHub Desktop.
SQL Making Sense
postgres=# select NULL + 4;
?column?
----------
(1 row)
postgres=# select SUM(foo) from (select NULL::integer as foo UNION all select 1) x;
sum
-----
1
(1 row)
postgres=# select SUM(foo) from (select NULL::integer as foo UNION all select 1) x where foo = 5;
sum
-----
(1 row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment