Recall & Review
beginner
What does the SQL
SUM() function do?The
SUM() function adds up all the values in a numeric column and returns the total.Click to reveal answer
beginner
How do you use the
SUM() function in a SQL query?You write
SELECT SUM(column_name) FROM table_name; to get the total of all values in that column.Click to reveal answer
intermediate
Can
SUM() be used with GROUP BY? What does it do then?Yes,
SUM() can be used with GROUP BY to add values for each group separately.Click to reveal answer
intermediate
What happens if the column used in
SUM() contains NULL values?The
SUM() function ignores NULL values and only adds the non-NULL numbers.Click to reveal answer
beginner
Is it possible to use
SUM() on non-numeric columns?No,
SUM() only works on numeric columns like integers or decimals.Click to reveal answer
What does
SELECT SUM(price) FROM sales; return?✗ Incorrect
The
SUM() function adds all values in the price column.If a column has NULL values, how does
SUM() treat them?✗ Incorrect
SUM() skips NULL values and sums only non-NULL numbers.Which SQL clause is used with
SUM() to get totals per category?✗ Incorrect
GROUP BY groups rows so SUM() totals each group.Can you use
SUM() on a text column?✗ Incorrect
SUM() requires numeric data types to work.What will this query return?
SELECT SUM(quantity) FROM orders WHERE quantity > 5;✗ Incorrect
The
WHERE clause filters rows before SUM() adds values.Explain how the
SUM() function works in SQL and give a simple example.Think about adding numbers in a column.
You got /3 concepts.
Describe how you would use
SUM() with GROUP BY to find totals per category.Imagine adding sales per product type.
You got /3 concepts.