Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions part1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* Part 1 */
Select c.customerName as "Customer Name", concat(emp.lastName, ' ', emp.firstName) as "Sales Rep"
From customers c
Join employees emp on c.salesRepEmployeeNumber = emp.employeeNumber
order by c.customerName ASC;
6 changes: 6 additions & 0 deletions part2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* Part 2 */
Select p.productName as "Product Name", sum(orde.priceEach) as "Total Sale", sum(orde.quantityOrdered) as "Total # Order"
From orderdetails orde
Join products p On orde.productCode = p.productCode
Group By p.productName
Order By sum(orde.priceEach) desc;
4 changes: 4 additions & 0 deletions part3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Part 3 */
Select distinct status, count(status) from orders
Group by status
Order by status asc;
6 changes: 6 additions & 0 deletions part4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* Part 4 */
Select p.productLine as "Product Line", sum(od.quantityOrdered) as "# Sold"
from products p
join orderdetails od
group by p.productLine
order by sum(od.quantityOrdered) desc;
9 changes: 9 additions & 0 deletions part5.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* Part 5 */
Select concat(emp.lastName, ' ', emp.firstName) as "Sales Rep", sum(orde.priceEach) as "Total Sale"
From employees emp
Join customers c on emp.employeeNumber = c.salesRepEmployeeNumber
Join orders o on c.customerNumber = o.customerNumber
Join orderdetails orde on o.orderNumber = orde.orderNumber
Where emp.jobTitle = "Sales Rep"
group by concat(emp.lastName, ' ', emp.firstName)
order by sum(orde.priceEach) desc;
4 changes: 4 additions & 0 deletions part6.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Select monthname(paymentDate) "Month", year(paymentDate) as "Year", amount as "Total Amount"
from payments
group by monthname(paymentDate) , year(paymentDate)
order by paymentDate asc;