CARVIEW |
SQL Functions and Queries Quiz
Quiz on SQL Operators & Aggregates
Question 1
Which operator would you use to filter records where a column value is within a range?
IN
BETWEEN
LIKE
EXISTS
Question 2
What is the output of SELECT COUNT(DISTINCT department) FROM employees; if 5 departments exist but 3 have NULL values?
5
2
3
8
Question 3
Which GROUP BY clause would correctly summarize sales data by both region and product category?
GROUP BY region, category
GROUP BY ALL
GROUP BY *
GROUP BY region AND category
Question 4
A correlated subquery differs from a regular subquery because it:
Returns only one row
References columns from the outer query
Must use EXISTS operator
Cannot be used with UPDATE statements
Question 5
Which aggregate function would you use to identify the earliest hire date in a table?
SUM()
MIN()
FIRST()
OLDEST()
Question 6
What does HAVING COUNT(*) > 5 do in a GROUP BY query?
Filters groups with more than 5 rows
Limits the output to 5 rows
Counts only the first 5 rows per group
Sorts groups by size
Question 8
What is the result of SELECT SUM(salary)/COUNT(*) FROM employees; if one employee has a NULL salary?
Average salary including NULL as zero
Average salary excluding NULL
Division error
NULL
Question 9
Which query finds products priced above the average?
SELECT * FROM products WHERE price > AVG(price);
SELECT * FROM products WHERE price > (SELECT AVG(price) FROM products);
SELECT * FROM products HAVING price > AVG(price);
SELECT * FROM products GROUP BY id HAVING price > AVG(price);
Question 10
What does GROUP BY ROLLUP(region, department) do?
Groups by region only
Creates hierarchical subtotals (region → department → grand total)
Randomizes group order
Filters NULL groups
There are 10 questions to complete.