Pine Valley Practice Exercise

advertisement
SQL Practice Set #1 Queries
PINE VALLEY DATABASE
customer
customer_id
1
2
3
4
5
6
customer_name
Contemporary Casuals
Value Furniture
Home Furnishings
Eastern Furniture
Impressions
Furniture Gallery
customer_address
1355 S. Hines Blvd.
15145 S.W. 17th St.
1900 Allard Ave.
1925 Beltline Rd
5585 Westcott Ct.
325 Flatiron Dr.
customer_city
Gainesville
Plano
Albany
Carteret
Sacramento
Boulder
order
order_id
1
2
3
4
5
6
7
customer_zip
326017509412209070089420680514-
orderline
order_date customer_id
9/9/2000
4
10/4/2000
3
7/19/2000
1
11/1/2000
6
7/28/2000
4
8/17/2000
6
8/17/2000
3
product
product_id product_description
1 End Table
2 Coffee Table
3 Computer Desk
4 Entertainment Center
5 Writer's Desk
6 8-Drawer Dresser
7 48" Bookcase
8 48" Bookcase
9 96" Bookcase
10 96" Bookcase
11 4-Drawer Dresser
12 8 Drawer Dresser
13 Nightstand
14 Writer's Desk
customer_state
FL
TX
NY
NJ
CA
CO
product_finish unit_price on_hand
Cherry
$175.00
8
Birch
$200.00
4
Oak
$375.00
5
Maple
$650.00
3
Oak
$325.00
0
Birch
$750.00
5
Walnut
$150.00
5
Oak
$175.00
2
Walnut
$225.00
4
Oak
$200.00
4
Oak
$500.00
3
Oak
$800.00
2
Cherry
$150.00
5
Birch
$300.00
2
order_id
1
2
4
3
5
4
2
1
5
2
product_id
2
3
3
6
6
7
8
10
10
14
quantity
2
1
1
2
2
3
2
2
1
2
1) List id and description of products costing $500
or more.
2) List descriptions of all products finished in maple
and oak.
3) List description and finish of all bookcases
(repeat for desks) (repeat for dressers)
4) A customer wants a piece of furniture to fill a 4 ft
office space. What would you suggest?
5) Which customers have placed no orders?
6) For each order, list order id and customer name.
7) For each order id, how many products were
ordered?
8) For each order line, list order id, product
description, and item value (quantity * unit price)
9) For those customers who have ordered, how
many orders has each placed?
10) What are the names of customers who placed
orders in August 2000?
1
Download