0% found this document useful (0 votes)
10 views5 pages

Tech-DA Assessment 2 Lessons 4-7 v1 0124

The document outlines assessment tasks for lessons 4-7, focusing on SQL queries involving grouping, aggregate functions, advanced filtering, joins, and unions. Each lesson includes specific query requirements, such as filtering data based on conditions, calculating totals, and analyzing product orders. The tasks emphasize practical application of SQL concepts to retrieve and manipulate data from various tables.

Uploaded by

os 3 noobs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views5 pages

Tech-DA Assessment 2 Lessons 4-7 v1 0124

The document outlines assessment tasks for lessons 4-7, focusing on SQL queries involving grouping, aggregate functions, advanced filtering, joins, and unions. Each lesson includes specific query requirements, such as filtering data based on conditions, calculating totals, and analyzing product orders. The tasks emphasize practical application of SQL concepts to retrieve and manipulate data from various tables.

Uploaded by

os 3 noobs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

T-M

Assessment 2: Lessons 4-7

Lesson 4 – Grouping and Aggregate

Subjects:

• GROUP BY Keyword
• Aggregate Functions
• YEAR() function
• HAVING Clause

1. Write a query that displays the ProductID and total quantity of that product sold
from the Sales.SalesOrderDetail table.
Display only the products with an Order quantity (OrderQty) between 600 and
850 units.

2. Write a query that displays how many people with each Title there are in the
Persons table.
Sort the results according the number of people with the Title, in descending
order.
T-M

Lesson 5 – Advanced filtering

Subjects:

• SELECT DISTINCT
• SELECT TOP N
• IN OPERATOR
• BETWEEN OPERATOR
• LIKE OPERATOR
• NULL VALUES

1. Write a query that displays the Business Entity ID, First Name, Middle Name, Last
Name, and Modified Date from the Person.Person table.
Display the data only for the people whose name ends with the letter "O" and for
whom the Modified Date is not between the dates March 1, 2008 and Dec. 1,
2008.

2. Write a query that displays the Product number from the Sales.SalesOrderDetail
table for the products with a total order quantity over all the years between 600
and 850 units.
T-M

Lesson 6 – Diagram and Join Tables

Subjects:

• Database Diagrams
• Join

1. What are the 3 product colors with the highest order amounts ?

Instructions: Write a query that shows the total order amount for each product
color. Sort the results from highest to lowest, and display only the first three rows

Think which tables contain the detailed data for the orders and the products. Use
the ERD page for assistance.

2. Write a query that shows the 10 orders in 2013 (from the Order Header table) with
the highest SubTotals, where the customer's last name contains the string 'lan' and
the customer's first name does not contain the letter 'r'.

3. Check whether there are products in the Products table that were never sold. If so,
display the products’ codes and names.

Instructions:
Think what "never sold" means and how it is reflected in the data.
Think about what type of JOIN is appropriate, and between which tables.
T-M

Lesson 7 – Union and Conditions

Subjects:

• Union
• Case when

1. In order to better arrange the store and provide a larger display space for items
with a higher average order amount, analyze the average quantity of each product
ordered during May 2012.

To do this, write a query that answers the following:

a. The query will display the following columns:

i. Product ID

ii. Total Order Quantity for that product

iii. The number of order rows for the product (Count the number of rows
in which the product was ordered.)

iv. A verbal description of the average order amount, as follows:

1. The average order amount < 3 → “Low quantity”

2. The average order amount ≤ 6 → “Reasonable quantity”

3. Above 6 → “High quantity”

b. Sort the query results according to the average order amount in


descending order.

c. The order data is ProductID and OrderQty from the


Sales.SalesOrderDetail table.

d. Only the sales during May 2012 should be included. The date is calculated
from the OrderDate field in the Sales.SalesOrderHeader table.
T-M

e. Following is a preview of the query results:

You might also like