wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Data Analysis in SQL: Introduction

Total questions: 20

Worksheet time: 20mins

Name
Class
Date
1.

In a sales table, to compute total revenue per region, which query fragment is essential?

a)

HAVING amount with AVG(region)

b)

WHERE region with COUNT(amount)

c)

ORDER BY amount with MAX(region)

d)

GROUP BY region with SUM(amount)

2.

Which function is best for calculating the average order value per customer?

a)

SUM with ORDER BY customer

b)

AVG with GROUP BY customer

c)

COUNT with WHERE customer

d)

MAX with HAVING customer

3.

What does MIN(amount) compute within each GROUP BY category?

a)

The median value per group

b)

The total count per group

c)

The first value per group

d)

The lowest value per group

4.

Logical SQL order of execution begins with which step?

a)

FROM and JOIN build the row set

b)

SELECT evaluates aliases first

c)

GROUP BY forms categories first

d)

ORDER BY sorts rows before filters

5.

Which column list must match the GROUP BY semantics to avoid errors?

a)

All non-aggregated columns in SELECT

b)

All aggregated columns in WHERE

c)

All alias names in HAVING

d)

All sorted columns in ORDER BY

6.

Which function identifies the largest sale per store when grouped by store_id?

a)

AVG(sale_amount) across store

b)

MAX(sale_amount) per store

c)

COUNT(sale_amount) per store

d)

SUM(sale_amount) across store

7.

A report needs customers with more than 5 orders and average order value above $50. Which filter sequence is correct?

a)

SELECT COUNT(*) > 5 then AVG(total) > 50

b)

WHERE COUNT(*) > 5 and AVG(total) > 50

c)

HAVING COUNT(*) > 5 and AVG(total) > 50

d)

ORDER BY COUNT(*) > 5 then AVG(total) > 50

8.

When grouping by product_category, which SELECT list is valid?

a)

category, SUM(quantity), price

b)

COUNT(*), total_value, region

c)

category, AVG(price), MAX(price)

d)

SUM(quantity), MIN(quantity), supplier

9.

Which option correctly describes the purpose of GROUP BY?

a)

Partitions rows into sets for aggregation

b)

Sorts results alphabetically by category

c)

Applies filters to remove duplicate rows

d)

Combines columns for faster indexing

10.

Which clause is executed after GROUP BY and before SELECT is finalized?

a)

HAVING filters aggregated groups

b)

WHERE filters individual rows

c)

ORDER BY sorts grouped results

d)

FROM constructs initial dataset

11.

You need the average salary from the employees table. Which query correctly uses an aggregate function to produce one scalar value?

a)

SELECT SUM(salary) FROM employees;

b)

SELECT MAX(salary) FROM employees;

c)

SELECT AVG(salary) FROM employees;

d)

SELECT COUNT(salary) FROM employees;

12.

A report needs the highest order total, the lowest order total, and how many orders exist. Which combination of aggregate functions fulfills this?

a)

MAX(), MIN(), COUNT() together

b)

SUM(), AVG(), COUNT() together

c)

AVG(), MIN(), SUM() together

d)

MAX(), SUM(), AVG() together

13.

Which statement reflects the golden rule when using GROUP BY?

a)

All columns must appear in ORDER BY clause

b)

Only numeric columns may be aggregated

c)

Aggregates must be placed after GROUP BY

d)

Every SELECT column is grouped or aggregated

14.

Which statement correctly describes when to use the HAVING clause in SQL?

a)

To filter joins before tables are combined

b)

To filter groups after aggregate functions are computed

c)

To filter columns selected in the projection

d)

To filter rows before grouping operations occur

15.

Why is the condition WHERE SUM(amount) > 1000 incorrect in a grouped query?

a)

SUM must appear only in the ORDER BY clause

b)

WHERE cannot reference aggregate results directly

c)

WHERE requires all columns to be grouped

d)

SUM cannot be used with numeric columns

16.

In the query SELECT category, COUNT(id), SUM(amount) FROM sales GROUP BY category HAVING COUNT(id) > 5 ORDER BY SUM(amount) DESC, what is the role of ORDER BY SUM(amount) DESC?

a)

Sorts rows before grouping by category

b)

Sorts groups by total amount descending

c)

Computes sums for each category first

d)

Filters groups with larger total amounts

17.

Which option best contrasts WHERE and HAVING in grouped queries?

a)

WHERE filters groups; HAVING filters rows

b)

WHERE filters rows; HAVING filters groups

c)

Both WHERE and HAVING filter groups

d)

Both WHERE and HAVING filter rows

18.

Which clause is executed first in SQL’s logical processing order?

a)

ORDER BY sorts final results

b)

WHERE clause filters raw rows

c)

FROM clause identifies tables

d)

SELECT clause processes columns

19.

After rows are grouped, which clause filters those groups before column selection?

a)

ORDER BY filters groups post-grouping

b)

WHERE filters groups post-grouping

c)

HAVING filters groups post-grouping

d)

SELECT filters groups post-grouping

20.

A query is written as SELECT ... FROM ... WHERE ... GROUP BY ... HAVING ... ORDER BY .... Which statement best describes the relationship between written syntax order and logical processing?

a)

Logical order starts at SELECT

b)

Syntax order starts at FROM

c)

They are identical step by step

d)

Logical order starts at FROM