CpS 301 Intro to Database

SQL Exercise 2

Average time to complete: 4 hours

GitHub Submission Repo

Instructions

  1. Create queries that answer the questions below using the database from exercise 1. As in exercise 1, use a text editor to save each query in a separate file named q1.sql, q2.sql, etc.

  2. Create a report containing all of the elements specified in SQL Exercise 1. Use the procedure from Exercise 1 to submit your answers and review the autograder results. Use the GitHub Submission Repo link on this page to submit. As in Exercise 1, there is no deduction for up to 3 submissions.

Questions

  1. List the order number, date, customer number, and first and last customer name for orders placed in January 2015 by Colorado customers, but shipped to Washington addresses. The customer first and last name should appear in a single (combined) column in the result labeled CustName. Sort by order number.

  2. List the employee number, first and last name, and phone number of employees who have taken orders in January 2015 from customers with balances greater than $200. Design your query to eliminate duplicate rows from the result. Sort by employee number.

  3. List the product number, name, and price of all products ordered by customers C0954327 and C2388597 in January 2015, sorted by descending product price. Design your query to eliminate duplicate rows from the result.

  4. List the order number, date, full customer name, and total order dollar amount (labeled TotOrdAmt) for orders placed on 1/23/2015, sorted by order number. The total order dollar amount should take into account both the quantity and product price of each product in the order.

  5. List the product number, name, total quantity of products ordered (labeled ProdQty), and total order dollar amount (labeled TotOrdAmt) for orders placed in January 2015, sorted by product number. Include only products whose January 2015 total quantity ordered is greater than 5.