SQL Database Aggregation and Groups Quiz
A 50-question quiz exploring aggregate functions, grouping rules, filtering with HAVING, and practical summarization patterns.
Question 1
A reporting tool needs to show how many orders each customer has placed. Which aggregate function is typically used to count how many rows belong to each customer?
Question 2
When summarizing monthly sales amounts, which function adds up the numeric column across all rows in each month?
Question 3
A manager wants the highest salary in each department. Which aggregate produces the value requested?
Question 4
An HR dashboard displays the average age of employees grouped by role. Which function produces this average?
Question 5
A school needs to know the lowest test score in each class. Which aggregate should they rely on?
Question 6
If a product table groups rows by category, what must be true about columns listed outside the aggregates?
Question 7
A data analyst wants to filter groups after they are formed. Which clause performs filtering at the group level?
Question 8
In a summary of product categories, suppose one category contains NULL prices. How does SUM treat NULL values?
Question 9
A store wants to know how many distinct brands they carry. What aggregate pattern captures unique items?
Question 10
When summarizing sales per region, what ensures each region appears once in the output?
Question 11
A report shows average review scores grouped by product. Which part of the query decides the grouping category?
Question 12
A warehouse dashboard needs only categories whose total inventory exceeds 500 units. Which pattern accomplishes this?
Question 13
An analyst wants the number of employees with salaries above 100k per department. What combination is appropriate?
Question 14
When grouping by country, why must columns like 'city' appear only inside aggregates unless grouped?
Question 15
Why does COUNT(*) return a number even when all values in a column are NULL?
Question 16
A report needs the average order value per customer. Why can high-value outliers affect AVG significantly?
Question 17
In a grouped summary of shipments per city, which statement is true about ORDER BY?
Question 18
A marketing team wants to know which campaign brought in the fewest sign-ups. Which function identifies this lowest value?
Question 19
If a category contains only NULL values in a numeric column, what is the result of AVG on that column?
Question 20
A team summarizes total hours worked per project. Which pattern accurately produces one row per project?
Question 21
In a grouped report, a manager wants to exclude categories with fewer than 5 items. Which clause applies this filter?
Question 22
When grouping by country, why might two groups show identical totals yet appear separately?
Question 23
Why does COUNT(col) produce a smaller number than COUNT(*) in some groups?
Question 24
A dataset of sales transactions needs a summary of total revenue for each store. What aggregate pattern accomplishes this?
Question 25
A food delivery service evaluates drivers based on total deliveries per week. Which combination expresses this summary?
Question 26
A manager wants to count how many employees belong to each department. What does this query produce?
SELECT department, COUNT(*) FROM employees GROUP BY department;Question 27
This query totals order amounts by customer. What do the results represent?
SELECT customer_id, SUM(amount) FROM orders GROUP BY customer_id;Question 28
What does this grouped query show about inventory levels?
SELECT category, MIN(stock) FROM items GROUP BY category;Question 29
This summary shows the highest score per class. What does the query produce?
SELECT class_id, MAX(score) FROM results GROUP BY class_id;Question 30
A company wants to know the number of tickets handled per agent. What summary does this produce?
SELECT agent_id, COUNT(*) FROM tickets GROUP BY agent_id;Question 31
This query calculates per-product average rating. What emerges in the result?
SELECT product_id, AVG(rating) FROM reviews GROUP BY product_id;Question 32
A shop wants the total units sold per item. What does this grouped query return?
SELECT item_id, SUM(quantity) FROM sales GROUP BY item_id;Question 33
What does this filter accomplish when placed after grouping?
SELECT category, SUM(price) FROM products GROUP BY category HAVING SUM(price) > 2000;Question 34
In this grouped report, how does NULL affect the total?
SELECT region, SUM(amount) FROM payments GROUP BY region;Question 35
What result is produced by this grouped comparison?
SELECT dept, COUNT(*) FROM employees GROUP BY dept HAVING COUNT(*) >= 10;Question 36
This query sorts categories based on total sales. What happens in the result?
SELECT category, SUM(amount) AS total FROM sales GROUP BY category ORDER BY total DESC;Question 37
A grouped query lists average delivery time per city. What does this represent?
SELECT city, AVG(minutes) FROM deliveries GROUP BY city;Question 38
A restaurant wants to know how many distinct dishes each chef prepared. What does this query calculate?
SELECT chef_id, COUNT(DISTINCT dish) FROM cooking GROUP BY chef_id;Question 39
A grouped summary shows how many login attempts occurred per user. What does this accomplish?
SELECT user_id, COUNT(*) FROM logins GROUP BY user_id;Question 40
This query filters grouped totals to highlight top-performing products. What does it return?
SELECT product, SUM(revenue) AS total FROM sales GROUP BY product HAVING total > 10000;Question 41
A query computes maximum session duration per user. What pattern does the output reflect?
SELECT user_id, MAX(duration) FROM sessions GROUP BY user_id;Question 42
This grouped report shows how many events occurred on each date. What results appear?
SELECT event_date, COUNT(*) FROM events GROUP BY event_date;Question 43
A shop wants to know which brands have more than five products. What does this grouped query reveal?
SELECT brand, COUNT(*) AS c FROM products GROUP BY brand HAVING c > 5;Question 44
This query tracks average fulfillment time per warehouse. What do the results convey?
SELECT warehouse, AVG(fulfillment_days) FROM shipments GROUP BY warehouse;Question 45
How does this query treat customers without recorded purchases?
SELECT customer_id, SUM(total) FROM purchases GROUP BY customer_id;Question 46
What does this summary produce for each movie?
SELECT movie_id, COUNT(*) FROM ratings GROUP BY movie_id;Question 47
A query groups rows to track total hours logged per employee. What does this show?
SELECT employee_id, SUM(hours) FROM timesheets GROUP BY employee_id;Question 48
This grouped query finds the average price per supplier. What appears in the result?
SELECT supplier, AVG(price) FROM items GROUP BY supplier;Question 49
A company wants to flag products whose total revenue is below a threshold. What does this query return?
SELECT product_id, SUM(amount) AS revenue FROM sales GROUP BY product_id HAVING revenue < 5000;Question 50
In this report, what does the query reveal about temperature readings?
SELECT location, MAX(reading) FROM temperatures GROUP BY location;