You need one result row per region that includes the number of paid orders alongside the total order count. Which approach best meets this requirement?
SQL Grouping and Aggregation Online Quiz Questions
Use this free practice quiz with 10 questions to review SQL Grouping and Aggregation, test your knowledge, and prepare for your next test or exam.
The orders table has one row per order. Which approach calculates an order count and total revenue with one summary row per region?
- A
Group by region and calculate the count and sum in each region group.
- B
Use aggregate functions without GROUP BY to produce one row per region.
- C
Group by order_id to produce one summary row for each region.
- D
Select region and the aggregate values without grouping by region.
A query should exclude cancelled orders before calculating regional revenue, then keep only regions whose resulting revenue exceeds $10,000. Which filtering arrangement is appropriate?
- A
Use HAVING for cancelled orders and WHERE for the revenue threshold.
- B
Use WHERE for both conditions because both refer to order data.
- C
Use WHERE to exclude cancelled orders and HAVING to apply the group revenue threshold.
- D
Use HAVING for both conditions because the query includes an aggregate.
You want every cancelled order excluded from all regional aggregates. Where should the query apply the status condition?
- A
Put the status condition in WHERE before GROUP BY.
- B
Put the status condition in HAVING after GROUP BY.
- C
Put the status condition only in ORDER BY.
- D
Put the status condition in an aggregate without changing which rows enter the groups.
A query uses aggregate functions but has no GROUP BY clause. How is its input treated for aggregation?
- A
It produces one row for every distinct region.
- B
It produces one row per order, with the overall aggregate repeated.
- C
It treats the input as one group and produces an overall summary.
- D
It produces no result because aggregate functions require GROUP BY.
A one-to-many join repeats order rows. Which statement correctly describes using COUNT(DISTINCT order_id) when the query also has an inflated sum of order amounts?
- A
Use COUNT(DISTINCT order_id); it also removes repeated amounts from the sum.
- B
Use SUM(DISTINCT amount); equal amounts always belong to the same order.
- C
Count the joined rows and subtract the number of items from the revenue.
- D
COUNT(DISTINCT order_id) may fix the distinct-order count, but it does not repair an inflated sum.
Which approach calculates paid revenue for each region while returning a regional grouped result?
- A
Use
SUM(amount)and group by both region and status. - B
Group by region and sum a CASE expression that returns amount for paid orders and zero otherwise.
- C
Use
AVG(amount)with a WHERE condition that removes unpaid orders. - D
Use
SUM(amount)in HAVING to count paid revenue for each region.
A report groups orders by region and should show only regions with at least 100 orders. Which clause should filter the groups based on their order count?
- A
Use WHERE to test whether each region's completed order count meets the threshold.
- B
Use ORDER BY to remove regions below the threshold.
- C
Use HAVING to retain groups whose order count meets the threshold.
- D
Use GROUP BY to exclude regions with too few orders.
When selecting a column alongside aggregate values in a grouped query, what should be true of that non-aggregate column?
- A
A selected column outside an aggregate should identify the group, usually by appearing in GROUP BY.
- B
Any selected column may be omitted from GROUP BY as long as an aggregate appears somewhere in the query.
- C
Every selected column must be inside an aggregate, including the grouping column.
- D
A non-aggregate column belongs in HAVING rather than GROUP BY.
Which statement accurately compares CASE and aggregate FILTER for conditional aggregation?
- A
CASE works only in systems that support aggregate FILTER.
- B
Aggregate FILTER is supported by every SQL system, while CASE is not portable.
- C
CASE and FILTER must both be used in the same aggregate expression.
- D
Aggregate FILTER is a clear option where supported, and CASE inside an aggregate is a portable pattern.
Related study packs and tools
1 Network Security Foundations and Threats
Learn how network security goals, threat modeling, identity and access controls, and layered defenses help protect connected systems and support recovery.
1 Network Troubleshooting Method
Learn a disciplined workflow for defining network problems, gathering evidence, testing likely causes, applying controlled fixes, and confirming and documenting the results.
1 Networking Fundamentals
A medium-difficulty quiz on networking fundamentals, including communication roles, protocol layers, data units, and network models.
2 Protocols and Ports
A medium-difficulty quiz on interpreting network protocols, ports, and common traffic patterns.
2 Virtual Machines
A medium-difficulty quiz on virtual machine architecture, provisioning, networking, storage, and operations.
4 Mobile Connectivity
A 14-question quiz on applying mobile connectivity concepts to common settings, usage, and troubleshooting situations.
5 Cloud Service Models
A medium-difficulty quiz on applying and distinguishing IaaS, PaaS, and SaaS, including their responsibilities, trade-offs, and appropriate uses.
5 Diagnosing Mobile Device Problems
Learn to diagnose mobile-device power, battery, touchscreen, connectivity, app, and operating-system problems using safe checks and a systematic process.
5 Network Operations and Reliability
A medium-difficulty quiz on network operations, monitoring, configuration management, resilience, and recovery planning.
6 Security Operations and Incident Response
Learn how security teams monitor activity, manage vulnerabilities, respond to incidents, preserve digital evidence, and restore services safely.
7 Integrated Troubleshooting Practice
A practical workflow for isolating mixed hardware, display, storage, mobile-device, and network problems, protecting data, and verifying repairs.
8 Comprehensive Security+ Practice and Review
A scenario-focused guide to Security+ SY0-701 concepts, emphasizing evidence-based incident response, access control, cryptography, vulnerability handling, recovery objectives, and risk governance.