Assignment 3
docx
keyboard_arrow_up
School
Conestoga College *
*We aren’t endorsed by this school
Course
PROG8400
Subject
Information Systems
Date
Apr 3, 2024
Type
docx
Pages
8
Uploaded by SuperMoon13224
Assignment-3
Relational Database Design
(PROG8401-5)
Kiran Pandey - 8984569
Write SQL queries for each of the following statements. 1.
Write a SELECT statement that returns these columns: The count of the number of orders in the Orders table, The sum of the TaxAmount column in the Orders table
ANS:
2.
Write a SELECT statement that returns one row for each category
that has products. The statement should return these columns: The CategoryName column from the Categories table The number of products in each category The list price of the most expensive product in each category Sort the result set so the category with the most products appears first.
Ans:
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
3.
Write a SELECT statement that returns one row for each customer that has orders. The statement should return these columns: The EmailAddress column from the Customers table The total price of the items the customer has ordered (Hint: multiply the item price in the OrderItems table by the quantity in the OrderItems table) The total discount applied to the items the customer has ordered (Hint: multiply the discount amount column in the OrderItems table by the quantity in the OrderItems table) Sort the result set in descending sequence by the price total for each customer.
Ans:
4.
Write a SELECT statement that returns one row for each customer that has orders. The statement should return these columns: The EmailAddress column from the Customers table A count of the number of orders for each customer The total amount for the orders for each customer (Hint: First, subtract the discount amount from the price. Then, multiply by the quantity.) Return only those rows where the customer has more than 1 order. Sort the result set in descending sequence by the sum of the line item amounts.
Ans:
5.
Modify the solution to exercise 4 so it only counts and totals line items that have an ItemPrice value that’s greater than 400. Ans:
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
6.
Write a SELECT statement that answers this question: What is the total amount ordered for each product? Return these columns: The product name from the Products table The total amount for each product in the OrderItems table (Hint: You can calculate the total by subtracting the discount amount from the item price and then multiplying it by the quantity) Use the ROLLUP operator to include a row that gives the grand total.
Ans:
7.
Write a SELECT statement that answers this question: Which customers have ordered more than one type of product? Return these columns: The email address from the Customers table The count of distinct products from the customer’s orders
Ans: