Question
Write SQL to answer the following questions based on the Pine Valley Furniture Company database. Note: the Pine Valley database is the one containing four
Write SQL to answer the following questions based on the Pine Valley Furniture Company database. Note: the Pine Valley database is the one containing four tables (Customer, Order, OrderLine, and Product), which you can create by using CREATE_PV.txt and LOAD_PV.txt.
1. Modify the Product_T table by adding an attribute QtyOnHand that can be used to track the finished goods inventory. The field should be an integer field of five characters and should accept only positive numbers.
2. List the customers who live in California or Washington. Order them by zip code, from high to low.
3. List the number of customers living at each state that is included in the Customer_T table.
4. Display the product line ID and the average standard price for all products in each product line.
5. For every product that has been ordered, display the product ID and the total quantity ordered (label this result TotalOrdered). List the most popular product first and the least popular last.
6. For each customer, list the CustomerID and total number of orders placed.
7. Display the product ID and the number of orders placed for each product. Show the results in decreasing order by the number of times the product has been ordered and label this result column NumOrders.
8. For each customer who had more than two orders, list the CustomerID and the total number of orders placed.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started