Challenge - 5 Problems
Aggregate Functions Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Understanding COUNT with NULL values
Consider a table Employees with a column
Bonus that contains some NULL values. What will be the result of the query SELECT COUNT(Bonus) FROM Employees;?Attempts:
2 left
💡 Hint
COUNT(column) ignores NULL values.
✗ Incorrect
The COUNT function when used with a column counts only the rows where that column is NOT NULL. NULL values are ignored.
📋 Factual
intermediate2:00remaining
SUM function behavior with negative numbers
Given a table Sales with a column
Amount containing positive and negative values, what does SELECT SUM(Amount) FROM Sales; return?Attempts:
2 left
💡 Hint
SUM adds all values including negatives.
✗ Incorrect
The SUM function adds all values in the column, including negative numbers, resulting in the total net sum.
🔍 Analysis
advanced2:00remaining
AVG function with NULL values
What will be the output of the query
SELECT AVG(Score) FROM Results; if the Score column contains some NULL values?Attempts:
2 left
💡 Hint
AVG ignores NULL values in calculation.
✗ Incorrect
The AVG function calculates the average of non-NULL values only. NULLs are ignored and do not affect the average.
❓ Comparison
advanced2:00remaining
Difference between MAX and MIN with text data
Given a table Books with a column
Title containing book names, what do SELECT MAX(Title) FROM Books; and SELECT MIN(Title) FROM Books; return?Attempts:
2 left
💡 Hint
MAX and MIN on text use alphabetical order.
✗ Incorrect
MAX and MIN when used on text columns return the values that come last and first alphabetically, respectively.
❓ Reasoning
expert3:00remaining
Combining aggregate functions with GROUP BY
Consider a table Orders with columns
CustomerID and OrderAmount. What does the query SELECT CustomerID, COUNT(*), SUM(OrderAmount) FROM Orders GROUP BY CustomerID; produce?Attempts:
2 left
💡 Hint
GROUP BY groups rows by customer.
✗ Incorrect
The query groups orders by each customer, then counts orders and sums amounts per customer.