1.       [SQL Week 2 Question 200-505]  You

1.       [SQL Week 2 Question 200-505]  You want to report on a certain group of your products.  Select

a.       Only customers who have a balance of 0

b.       Only shipments which were sent by employees whose employee location is California, Maryland, or New York

c.       Only products which have had a shipment

d.       Only employees who have made a shipment

e.       Only customers who have received a shipment

f.        Compute the total quantity of shipments which meet these criteria. Here we want the number of items  shipped.  If you have one shipment of 10 items, and another shipment of 20 items, this number should be 30.

g.       Aggregate it by manufacturer and by product name.  This means each manufacturer/product name combination appears on only one row in the table.  If a manufacturer makes more than one product, it’s OK if it shows up once per product.

h.       Sort it descending by the sum of the shipment quantity, so the largest shipment quantity shows up on top.  Within shipment quantities, sort it alphabetically on manufacturer and then product name.


Your results should look a little bit like this.  Your data may or may not match this example.


Need customized help? Order now
user img


12-09-20 | 10:08:00

Select Manufacturer, ProductName, sum(quantity) FROM Customer c
join shipment s
On c.idCustomer=s.Customer_idCustomer
Join employee e
On s.employee_idEmployee=e.idEmployee
Join product p
ON p.idproduct=s.Product_idProduct
where Balance=0 and EmpLocation in('CA','MD','NY') AND Product_idProduct >0 and employee_idEmployee>0 and Customer_idCustomer>0 group by manufacturer,ProductName order by sum(quantity) desc, manufacturer asc, productname asc;

Related Question