-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment08.sql
More file actions
40 lines (36 loc) · 1.58 KB
/
Copy pathAssignment08.sql
File metadata and controls
40 lines (36 loc) · 1.58 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
--Name: Michael Quatrani
--Description: Assignment 8 Exercises 30-33, p 266
--Date: November 9th, 2013
/**Exercise 30**/
/**Write an SQL query to produce a list of all the products(i.e. product description) and the number of times
each product has been ordered.**/
/**I think I am doing this correctly, I am not sure if this question is looking for an aggregate function**/
Select PT.productDescription, OL.productID, OL.orderedQuantity
From Product_T PT, OrderLine_T OL
where OL.productID=PT.productID
order by OL.orderedQuantity
/**Exercise 31**/
/**Display the customer ID, name, and order ID for all customer orders. For those customers who do not have any
orders, include them in the display only once**/
/**Appears Correct**/
Select CT.CustomerID, CT.CustomerName, OT.OrderID
From Customer_T CT
left outer join Order_t OT on
CT.CustomerID = OT.CustomerID
/**Exercise 32**/
/**Display the EmployeeId and EmployeeName for those employees who do not possess the skill Router.
Display the results in order by EmployeeName.**/
/**Appears to be correct Assuming RT1 is router**/
Select Emp.EmployeeName, Emp.EmployeeID, ES.EmployeeID, ES.SkillID
From Employee_T Emp, EmployeeSkills_T ES
Where not(ES.SkillID = 'RT1')
and Emp.EmployeeID=ES.EmployeeID
Order by Emp.EmployeeName
/**Exercise 33**/
/**Display the name of customer 16 and the names of all the customers that are in the same zip code as customer
16. (Be sure the query will work for any customer)**/
/**Appears Correct**/
Select CT.CustomerName, CT.CustomerID
From Customer_T CT
Where CT.CustomerID = '16'
or CT.CustomerPostalCode = '13440'