Does SUM discard rows that have 0 values if it is applied to a column in a table? For example,
SELECT SUM(CREDIT_HRS)... FROM tablename
No. The SUM function, as well as all other aggregate functions, includes all non-NULL values, and zero is non-NULL. NULLs are ignored, but NULLs are not the same as zeroes.
But when you stop and think about it, what would the difference to the final answer be if zeroes were excluded, as compared to included? Would the answer be any different?
Dig Deeper on Oracle and SQL
Related Q&A from Rudy Limeback
Read an example of an SQL case expression from our SQL expert Rudy Limeback. Continue Reading
Read SQL expert Rudy Limeback's advice for counting combinations in a table with SQL's GROUP BY clause Continue Reading
Read about the Mimer Validator, a tool used to verify your SQL code, in this tip from SQL expert Rudy Limeback. Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.