Skip to content

Instantly share code, notes, and snippets.

@dandye
Created December 18, 2013 21:10
Show Gist options
  • Save dandye/8029893 to your computer and use it in GitHub Desktop.
Save dandye/8029893 to your computer and use it in GitHub Desktop.
AVG() ignores NULL values
CREATE TABLE #LocalTempTable(
somenum INT);
INSERT into #LocalTempTable values (2);
INSERT into #LocalTempTable values (4);
INSERT into #LocalTempTable values (6);
select * from #LocalTempTable;
select avg(somenum)
from #LocalTempTable;
INSERT into #LocalTempTable values (NULL);
select * from #LocalTempTable;
select avg(somenum)
from #LocalTempTable;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment