-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassignments_section3.sql
More file actions
64 lines (25 loc) · 1.16 KB
/
assignments_section3.sql
File metadata and controls
64 lines (25 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
-- Connect to database
-- ASSIGNMENT 1: Subqueries in the SELECT clause
-- View the products table
-- View the average unit price
-- Return the product id, product name, unit price, average unit price,
-- and the difference between each unit price and the average unit price
-- Order the results from most to least expensive
-- ASSIGNMENT 2: Subqueries in the FROM clause
-- Return the factories, product names from the factory
-- and number of products produced by each factory
-- All factories and products
-- All factories and their total number of products
-- Final query with subqueries
-- ASSIGNMENT 3: Subqueries in the WHERE clause
-- View all products from Wicked Choccy's
-- Return products where the unit price is less than
-- the unit price of all products from Wicked Choccy's
-- ASSIGNMENT 4: CTEs
-- View the orders and products tables
-- Calculate the amount spent on each product, within each order
-- Return all orders over $200
-- Return the number of orders over $200
-- ASSIGNMENT 5: Multiple CTEs
-- Copy over Assignment 2 (Subqueries in the FROM clause) solution
-- Rewrite the Assignment 2 subquery solution using CTEs instead