If you try the following code without the zero, it returns the correct average of 1.
Add the zero, and it returns the incorrect average of 0.
Is it me? Why?
DECLARE @Test AS TABLE(n INTEGER) INSERT INTO @Test VALUES(1),(1),(1),(1),(1),(0),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1) SELECT AVG(n) AS [n Average], SUM(n) AS [n Sum] FROM @Test
+__+