Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Homework 2

Write SQL queries for the Pine Valley Furniture Company Database to answer the following questions:
1. Write a SQL query to display order ID and order date for all the orders made by customers in
the territory of Southwest (use WHERE command to join tables).
.
SELECT Order_Id, Order_date From Order_t, Customer_t, Territory_t,
DOES_Business_IN_t
WHERE Customer_id=Customer_id and Territory_id=Territory_id and
Territory_Name=Southwest

2. Use sub-query technique to write a SQL query to display order ID and order date for all the
orders made by customers in the territory of Southwest.
SELECT Order_ID, Order_Date FROM Order_t
WHERE Customer_ID in (SELECT Customer_ID FROM Customer_t WHERE
Customer_ID in (SELECT Customer_ID FROM Does_Business_IN_t WHERE
Territory_id in ( SELECT Territory_id FROM Territory_t WHERE
Territory_Name=Southwest)))

3. What are the product ID and product description for the products with a price larger than the
price of the product Computer Desk?
SELECT DISTINCT PRODUCT_ID,PRODUCT_DESC FROM table WHERE PRICE >
COMPUTER_DESK
OR
4. What are the order IDs of the orders that have included the product with the largest price?
SELECT ORDER_ID ,PRODUCT_ID FROM TABLE ORDER BY PRICE DESC
OR
Select * from table where price in (select max(price) from table)
Order by product_id

5. Give 10% discount to all the products manufactured by the product line 3.
UPDATE Products

SET Price = Price * 0.9


WHERE Product_line = 3;

You might also like