0
0
DBMS Theoryknowledge~20 mins

Aggregate functions (COUNT, SUM, AVG, MAX, MIN) in DBMS Theory - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Aggregate Functions Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2: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;?
ACounts only rows where Bonus is NOT NULL
BCounts only rows where Bonus is NULL
CCounts all rows including those where Bonus is NULL
DReturns the total number of NULL values in Bonus
Attempts:
2 left
💡 Hint
COUNT(column) ignores NULL values.
📋 Factual
intermediate
2: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?
ACount of all rows with non-NULL Amount
BSum of all negative values only
CSum of all positive values only
DSum of all values including negatives and positives
Attempts:
2 left
💡 Hint
SUM adds all values including negatives.
🔍 Analysis
advanced
2: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?
AAverage excluding NULL values
BCount of non-NULL Score values
CNULL as output if any NULL exists
DAverage including NULL values counted as zero
Attempts:
2 left
💡 Hint
AVG ignores NULL values in calculation.
Comparison
advanced
2: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?
AMAX returns longest title; MIN returns shortest title
BMAX returns title with highest alphabetical order; MIN returns lowest alphabetical order
CMAX returns last inserted title; MIN returns first inserted title
DBoth return NULL if any title is NULL
Attempts:
2 left
💡 Hint
MAX and MIN on text use alphabetical order.
Reasoning
expert
3: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?
ATotal number of orders and total amount for all customers combined
BTotal number of orders and average amount for all customers combined
CTotal number of orders and total amount for each customer
DTotal number of customers and total amount of all orders
Attempts:
2 left
💡 Hint
GROUP BY groups rows by customer.