Tech-DA Assessment 2 Lessons 4-7 v1 0124
Tech-DA Assessment 2 Lessons 4-7 v1 0124
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
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
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
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.
i. Product ID
iii. The number of order rows for the product (Count the number of rows
in which the product was ordered.)
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