SQL Database Aggregation and Groups Quiz

SQL Database
0 Passed
0% acceptance

A 50-question quiz exploring aggregate functions, grouping rules, filtering with HAVING, and practical summarization patterns.

50 Questions
~100 minutes
1

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?

A
COUNT
B
SUM
C
MIN
D
DATEDIFF
2

Question 2

When summarizing monthly sales amounts, which function adds up the numeric column across all rows in each month?

A
SUM
B
MAX
C
AVG
D
INDICATOR
3

Question 3

A manager wants the highest salary in each department. Which aggregate produces the value requested?

A
MAX
B
SUM
C
COUNT
D
DISTINCT
4

Question 4

An HR dashboard displays the average age of employees grouped by role. Which function produces this average?

A
AVG
B
MAX
C
COUNT
D
REGEXP
5

Question 5

A school needs to know the lowest test score in each class. Which aggregate should they rely on?

A
MIN
B
SUM
C
COUNT
D
TOP
6

Question 6

If a product table groups rows by category, what must be true about columns listed outside the aggregates?

A
They must appear in the GROUP BY clause
B
They must all be numeric
C
They must be sorted alphabetically
D
They must be unique always
7

Question 7

A data analyst wants to filter groups after they are formed. Which clause performs filtering at the group level?

A
HAVING
B
WHERE
C
ORDER BY
D
LIMIT
8

Question 8

In a summary of product categories, suppose one category contains NULL prices. How does SUM treat NULL values?

A
They are ignored
B
They count as zero
C
They cause the entire SUM to become NULL
D
They convert to empty strings
9

Question 9

A store wants to know how many distinct brands they carry. What aggregate pattern captures unique items?

A
COUNT(DISTINCT brand)
B
SUM(brand)
C
DISTINCT(brand)
D
MAX(DISTINCT brand)
10

Question 10

When summarizing sales per region, what ensures each region appears once in the output?

A
Using GROUP BY region
B
Using DISTINCT region only
C
Sorting by region
D
Using LIMIT 1
11

Question 11

A report shows average review scores grouped by product. Which part of the query decides the grouping category?

A
GROUP BY product_id
B
HAVING AVG(score) > 3
C
ORDER BY score
D
COUNT(*)
12

Question 12

A warehouse dashboard needs only categories whose total inventory exceeds 500 units. Which pattern accomplishes this?

A
GROUP BY category HAVING SUM(quantity) > 500
B
WHERE SUM(quantity) > 500
C
ORDER BY SUM(quantity) > 500
D
DISTINCT category > 500
13

Question 13

An analyst wants the number of employees with salaries above 100k per department. What combination is appropriate?

A
GROUP BY department with COUNT(*) filtered by HAVING
B
COUNT(*) only
C
ORDER BY department
D
SUM(department)
14

Question 14

When grouping by country, why must columns like 'city' appear only inside aggregates unless grouped?

A
Ungrouped detail columns don't have defined values in grouped results
B
City must be numeric
C
City must be unique
D
City determines sorting only
15

Question 15

Why does COUNT(*) return a number even when all values in a column are NULL?

A
COUNT(*) counts rows, not non-NULL values
B
COUNT(*) converts NULLs to zero
C
COUNT(*) ignores rows automatically
D
COUNT(*) only counts text columns
16

Question 16

A report needs the average order value per customer. Why can high-value outliers affect AVG significantly?

A
AVG is sensitive to extreme numeric values
B
AVG ignores all values above the median
C
AVG rounds all values to nearest integer
D
AVG only includes values below the mean
17

Question 17

In a grouped summary of shipments per city, which statement is true about ORDER BY?

A
ORDER BY can use aggregates even if GROUP BY cannot
B
ORDER BY requires all columns grouped
C
ORDER BY must appear before GROUP BY
D
ORDER BY cannot sort summary rows
18

Question 18

A marketing team wants to know which campaign brought in the fewest sign-ups. Which function identifies this lowest value?

A
MIN
B
COUNT
C
MAX
D
ABS
19

Question 19

If a category contains only NULL values in a numeric column, what is the result of AVG on that column?

A
NULL
B
0
C
An error
D
The highest number
20

Question 20

A team summarizes total hours worked per project. Which pattern accurately produces one row per project?

A
GROUP BY project_id
B
ORDER BY project_id
C
DISTINCT project_id
D
LIMIT project_id
21

Question 21

In a grouped report, a manager wants to exclude categories with fewer than 5 items. Which clause applies this filter?

A
HAVING COUNT(*) >= 5
B
WHERE COUNT(*) >= 5
C
COUNT(*) WHERE >= 5
D
ORDER BY COUNT(*)
22

Question 22

When grouping by country, why might two groups show identical totals yet appear separately?

A
They may represent different countries with same numeric result
B
GROUP BY merges numeric results automatically
C
Aggregates remove country entirely
D
HAVING splits values based on text length only
23

Question 23

Why does COUNT(col) produce a smaller number than COUNT(*) in some groups?

A
COUNT(col) skips NULL values
B
COUNT(col) counts only even numbers
C
COUNT(col) excludes first rows
D
COUNT(col) requires grouping by all columns
24

Question 24

A dataset of sales transactions needs a summary of total revenue for each store. What aggregate pattern accomplishes this?

A
SUM(amount)
B
MAX(amount)
C
GROUP(amount)
D
FILTER(amount)
25

Question 25

A food delivery service evaluates drivers based on total deliveries per week. Which combination expresses this summary?

A
GROUP BY driver_id with COUNT(*)
B
COUNT(driver_id) only
C
ORDER BY COUNT(*) DESC
D
SUM(driver_id)
26

Question 26

A manager wants to count how many employees belong to each department. What does this query produce?

sql
SELECT department, COUNT(*) FROM employees GROUP BY department;
A
One row per department showing employee count
B
All employees without grouping
C
Departments sorted alphabetically only
D
Rows filtered to NULL departments only
27

Question 27

This query totals order amounts by customer. What do the results represent?

sql
SELECT customer_id, SUM(amount) FROM orders GROUP BY customer_id;
A
Total spending per customer
B
Only orders above average
C
Only one customer per row without totals
D
All orders merged into one sum
28

Question 28

What does this grouped query show about inventory levels?

sql
SELECT category, MIN(stock) FROM items GROUP BY category;
A
Lowest stock count within each category
B
Total stock across all categories
C
All items sorted by stock
D
Categories with NULL stock only
29

Question 29

This summary shows the highest score per class. What does the query produce?

sql
SELECT class_id, MAX(score) FROM results GROUP BY class_id;
A
The top score achieved in each class
B
Average scores per class
C
Only one row for all classes
D
Rows with NULL scores only
30

Question 30

A company wants to know the number of tickets handled per agent. What summary does this produce?

sql
SELECT agent_id, COUNT(*) FROM tickets GROUP BY agent_id;
A
Ticket count for each agent
B
Agents sorted alphabetically
C
Tickets with NULL agents only
D
All tickets from one agent
31

Question 31

This query calculates per-product average rating. What emerges in the result?

sql
SELECT product_id, AVG(rating) FROM reviews GROUP BY product_id;
A
Average rating for each product
B
Only products with rating=NULL
C
All reviews merged into one row
D
Highest rating across all products
32

Question 32

A shop wants the total units sold per item. What does this grouped query return?

sql
SELECT item_id, SUM(quantity) FROM sales GROUP BY item_id;
A
Total quantity sold for each item
B
Items sorted only
C
Sales before discounts only
D
A single total for all items
33

Question 33

What does this filter accomplish when placed after grouping?

sql
SELECT category, SUM(price) FROM products GROUP BY category HAVING SUM(price) > 2000;
A
Shows only categories whose total price exceeds 2000
B
Shows all categories regardless of price
C
Filters rows before grouping
D
Shows categories with zero totals
34

Question 34

In this grouped report, how does NULL affect the total?

sql
SELECT region, SUM(amount) FROM payments GROUP BY region;
A
NULL amounts are ignored by SUM
B
NULL amounts convert to zero
C
NULL amounts duplicate rows
D
NULL amounts cause SUM to fail completely
35

Question 35

What result is produced by this grouped comparison?

sql
SELECT dept, COUNT(*) FROM employees GROUP BY dept HAVING COUNT(*) >= 10;
A
Departments with at least 10 employees
B
Departments with fewer than 10 employees
C
All departments, unfiltered
D
Only employees without departments
36

Question 36

This query sorts categories based on total sales. What happens in the result?

sql
SELECT category, SUM(amount) AS total FROM sales GROUP BY category ORDER BY total DESC;
A
Categories appear ordered by highest total sales
B
Only the largest category appears
C
Rows are ordered alphabetically by category
D
Rows are unordered because aggregates cannot be sorted
37

Question 37

A grouped query lists average delivery time per city. What does this represent?

sql
SELECT city, AVG(minutes) FROM deliveries GROUP BY city;
A
Average delivery duration per city
B
Only fastest deliveries
C
Only the last delivery in each city
D
All deliveries merged together
38

Question 38

A restaurant wants to know how many distinct dishes each chef prepared. What does this query calculate?

sql
SELECT chef_id, COUNT(DISTINCT dish) FROM cooking GROUP BY chef_id;
A
Number of unique dishes prepared per chef
B
Total dishes prepared by all chefs
C
All dishes without grouping
D
Total number of chefs
39

Question 39

A grouped summary shows how many login attempts occurred per user. What does this accomplish?

sql
SELECT user_id, COUNT(*) FROM logins GROUP BY user_id;
A
Counts attempts for each user separately
B
Shows only users with failed logins
C
Shows only the final login attempt per user
D
Shows login attempts merged into one total
40

Question 40

This query filters grouped totals to highlight top-performing products. What does it return?

sql
SELECT product, SUM(revenue) AS total FROM sales GROUP BY product HAVING total > 10000;
A
Products generating more than 10,000 in revenue
B
All products regardless of revenue
C
Only products with NULL revenue
D
Only the product with the highest revenue
41

Question 41

A query computes maximum session duration per user. What pattern does the output reflect?

sql
SELECT user_id, MAX(duration) FROM sessions GROUP BY user_id;
A
Longest session achieved by each user
B
Average session duration globally
C
All session rows ungrouped
D
Shortest session for each user
42

Question 42

This grouped report shows how many events occurred on each date. What results appear?

sql
SELECT event_date, COUNT(*) FROM events GROUP BY event_date;
A
A count of events for each date
B
Only the latest event
C
Events merged into a single count
D
Dates with zero events only
43

Question 43

A shop wants to know which brands have more than five products. What does this grouped query reveal?

sql
SELECT brand, COUNT(*) AS c FROM products GROUP BY brand HAVING c > 5;
A
Brands with more than five items
B
Brands with exactly five items
C
Only brands with no items
D
All brands sorted alphabetically
44

Question 44

This query tracks average fulfillment time per warehouse. What do the results convey?

sql
SELECT warehouse, AVG(fulfillment_days) FROM shipments GROUP BY warehouse;
A
Average number of days each warehouse takes to fulfill orders
B
Only warehouses with negative values
C
Only the fastest warehouse
D
All shipments in one row
45

Question 45

How does this query treat customers without recorded purchases?

sql
SELECT customer_id, SUM(total) FROM purchases GROUP BY customer_id;
A
They do not appear because SUM requires at least one row
B
They appear with SUM = NULL
C
They appear with SUM = 0 automatically
D
They merge with other customers
46

Question 46

What does this summary produce for each movie?

sql
SELECT movie_id, COUNT(*) FROM ratings GROUP BY movie_id;
A
Number of ratings each movie received
B
Highest rating for each movie
C
Only movies with rating=NULL
D
Only the most rated movie
47

Question 47

A query groups rows to track total hours logged per employee. What does this show?

sql
SELECT employee_id, SUM(hours) FROM timesheets GROUP BY employee_id;
A
Total hours each employee logged
B
Only employees with zero hours
C
Only the employee with most hours
D
Hours merged into one number
48

Question 48

This grouped query finds the average price per supplier. What appears in the result?

sql
SELECT supplier, AVG(price) FROM items GROUP BY supplier;
A
Average item price for each supplier
B
Only suppliers without prices
C
All prices combined
D
Suppliers sorted alphabetically only
49

Question 49

A company wants to flag products whose total revenue is below a threshold. What does this query return?

sql
SELECT product_id, SUM(amount) AS revenue FROM sales GROUP BY product_id HAVING revenue < 5000;
A
Products generating less than 5000 in revenue
B
Products generating more than 5000
C
All products regardless of revenue
D
Products with no sales removed
50

Question 50

In this report, what does the query reveal about temperature readings?

sql
SELECT location, MAX(reading) FROM temperatures GROUP BY location;
A
Highest recorded temperature per location
B
Only readings equal to zero
C
All readings combined into one row
D
Only the lowest temperatures

QUIZZES IN SQL Database