From d043e7a6080fb9b4a38276f3025e75ad1248b9c7 Mon Sep 17 00:00:00 2001 From: Laura Godinez Date: Tue, 14 Jul 2020 00:48:44 -0400 Subject: [PATCH 1/2] Here is what i was able to do --- part1.sql | 4 ++++ part2.sql | 9 +++++++++ part3.sql | 4 ++++ part4.sql | 7 +++++++ part5.sql | 6 ++++++ 5 files changed, 30 insertions(+) create mode 100644 part1.sql create mode 100644 part2.sql create mode 100644 part3.sql create mode 100644 part4.sql create mode 100644 part5.sql diff --git a/part1.sql b/part1.sql new file mode 100644 index 0000000..8b482c2 --- /dev/null +++ b/part1.sql @@ -0,0 +1,4 @@ +SELECT customerName AS "Customer Name", +CONCAT(contactLastName, ', ',contactFirstName) as "Sales Rep" +FROM customers +ORDER BY customerName ASC; \ No newline at end of file diff --git a/part2.sql b/part2.sql new file mode 100644 index 0000000..f0562fe --- /dev/null +++ b/part2.sql @@ -0,0 +1,9 @@ +SELECT +products.productName AS "product Name", +orderdetails.quantityOrdered AS "Total Quantity Ordered", +(orderdetails.quantityOrdered * orderdetails.priceEach) AS "Total Sales" +FROM products +INNER JOIN orderdetails +ON products.productCode = orderdetails.productCode +GROUP BY products.productCode +ORDER BY (orderdetails.quantityOrdered * orderdetails.priceEach) DESC; \ No newline at end of file diff --git a/part3.sql b/part3.sql new file mode 100644 index 0000000..5dadfc5 --- /dev/null +++ b/part3.sql @@ -0,0 +1,4 @@ +SELECT Status AS "Order Status", COUNT(*) FROM +ORDERS +GROUP BY status +ORDER BY status ASC; \ No newline at end of file diff --git a/part4.sql b/part4.sql new file mode 100644 index 0000000..98d2fea --- /dev/null +++ b/part4.sql @@ -0,0 +1,7 @@ +SELECT pl.productLine, SUM(od.quantityOrdered) AS "# Sold" +FROM productLines pl +LEFT JOIN products p +ON pl.productLine = p.productLine +LEFT JOIN orderdetails od +ON p.productCode = od.productCode +GROUP BY productLine; \ No newline at end of file diff --git a/part5.sql b/part5.sql new file mode 100644 index 0000000..6f66ead --- /dev/null +++ b/part5.sql @@ -0,0 +1,6 @@ +SELECT CONCAT(e.firstName, " " , e.lastName) AS "Sales Rep" FROM employees e +LEFT JOIN customers c +ON e.employeeNumber = c.salesRepEmployeeNumber; + + +-- I dont really know how i can get the rest done. \ No newline at end of file From 6108e73f1d792b2e90dc38fdcc5652e2d1227fe5 Mon Sep 17 00:00:00 2001 From: Laura Godinez Date: Tue, 14 Jul 2020 00:58:44 -0400 Subject: [PATCH 2/2] part5 --- part5.sql | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/part5.sql b/part5.sql index 6f66ead..a6b309f 100644 --- a/part5.sql +++ b/part5.sql @@ -1,6 +1,8 @@ -SELECT CONCAT(e.firstName, " " , e.lastName) AS "Sales Rep" FROM employees e -LEFT JOIN customers c -ON e.employeeNumber = c.salesRepEmployeeNumber; - --- I dont really know how i can get the rest done. \ No newline at end of file +COUNT(o.orderNumber) AS "# Orders", IFNULL((od.quantityOrdered * od.priceEach), 0) AS "Total Sales" +FROM employees e JOIN customers c ON e.employeeNumber=c.salesRepEmployeeNumber +JOIN orders o ON o.customerNumber=c.customerNumber +JOIN orderdetails od ON od.orderNumber=o.orderNumber +WHERE e.jobTitle="Sales Rep" +GROUP BY 1 +ORDER BY 3 DESC; \ No newline at end of file