Timedora
Free Practice Quiz Question List

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.

10 questions
01
Choose one
1 point

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?

  1. A

    Group by both region and status, so each status gets a separate result row.

  2. B

    Group by region and use a conditional aggregate to count paid orders.

  3. C

    Filter the input to paid orders with WHERE, then count all orders by region.

  4. D

    Use HAVING to select paid rows before grouping.

02
Choose one
1 point

The orders table has one row per order. Which approach calculates an order count and total revenue with one summary row per region?

  1. A

    Group by region and calculate the count and sum in each region group.

  2. B

    Use aggregate functions without GROUP BY to produce one row per region.

  3. C

    Group by order_id to produce one summary row for each region.

  4. D

    Select region and the aggregate values without grouping by region.

03
Choose one
1 point

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?

  1. A

    Use HAVING for cancelled orders and WHERE for the revenue threshold.

  2. B

    Use WHERE for both conditions because both refer to order data.

  3. C

    Use WHERE to exclude cancelled orders and HAVING to apply the group revenue threshold.

  4. D

    Use HAVING for both conditions because the query includes an aggregate.

04
Choose one
1 point

You want every cancelled order excluded from all regional aggregates. Where should the query apply the status condition?

  1. A

    Put the status condition in WHERE before GROUP BY.

  2. B

    Put the status condition in HAVING after GROUP BY.

  3. C

    Put the status condition only in ORDER BY.

  4. D

    Put the status condition in an aggregate without changing which rows enter the groups.

05
Choose one
1 point

A query uses aggregate functions but has no GROUP BY clause. How is its input treated for aggregation?

  1. A

    It produces one row for every distinct region.

  2. B

    It produces one row per order, with the overall aggregate repeated.

  3. C

    It treats the input as one group and produces an overall summary.

  4. D

    It produces no result because aggregate functions require GROUP BY.

06
Choose one
1 point

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?

  1. A

    Use COUNT(DISTINCT order_id); it also removes repeated amounts from the sum.

  2. B

    Use SUM(DISTINCT amount); equal amounts always belong to the same order.

  3. C

    Count the joined rows and subtract the number of items from the revenue.

  4. D

    COUNT(DISTINCT order_id) may fix the distinct-order count, but it does not repair an inflated sum.

07
Choose one
1 point

Which approach calculates paid revenue for each region while returning a regional grouped result?

  1. A

    Use SUM(amount) and group by both region and status.

  2. B

    Group by region and sum a CASE expression that returns amount for paid orders and zero otherwise.

  3. C

    Use AVG(amount) with a WHERE condition that removes unpaid orders.

  4. D

    Use SUM(amount) in HAVING to count paid revenue for each region.

08
Choose one
1 point

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?

  1. A

    Use WHERE to test whether each region's completed order count meets the threshold.

  2. B

    Use ORDER BY to remove regions below the threshold.

  3. C

    Use HAVING to retain groups whose order count meets the threshold.

  4. D

    Use GROUP BY to exclude regions with too few orders.

09
Choose one
1 point

When selecting a column alongside aggregate values in a grouped query, what should be true of that non-aggregate column?

  1. A

    A selected column outside an aggregate should identify the group, usually by appearing in GROUP BY.

  2. B

    Any selected column may be omitted from GROUP BY as long as an aggregate appears somewhere in the query.

  3. C

    Every selected column must be inside an aggregate, including the grouping column.

  4. D

    A non-aggregate column belongs in HAVING rather than GROUP BY.

10
Choose one
1 point

Which statement accurately compares CASE and aggregate FILTER for conditional aggregation?

  1. A

    CASE works only in systems that support aggregate FILTER.

  2. B

    Aggregate FILTER is supported by every SQL system, while CASE is not portable.

  3. C

    CASE and FILTER must both be used in the same aggregate expression.

  4. D

    Aggregate FILTER is a clear option where supported, and CASE inside an aggregate is a portable pattern.