Skip to content

Instantly share code, notes, and snippets.

@townie
Last active October 29, 2015 01:16
Show Gist options
  • Save townie/312a7134a9deb678389b to your computer and use it in GitHub Desktop.
Save townie/312a7134a9deb678389b to your computer and use it in GitHub Desktop.
ds_bos_mysql_tutorial_Keith_and_Pam
ds_bos_mysql_tutorial_Keith_and_Pam
What customers are from the UK
What is the name of the customer who has the most orders?
What supplier has the highest average product price?
What category has the most orders?
5. What employee made the most sales (by number of sales)?
** 6. What employee made the most sales (by value of sales)?
** 7. What Employees have BS degrees? (Hint: Look at LIKE operator)
** 8. What supplier has the highest average product price assuming they have at least 2 products (Hint: Look at the HAVING operator)
@pwang1
Copy link

pwang1 commented Oct 29, 2015

  1. What Employees have BS degrees? (Hint: Look at LIKE operator)
    SELECT FirstName,LastName,Notes LIKE '% BS %' FROM Employees

@townie
Copy link
Author

townie commented Oct 29, 2015

What supplier has the highest average product price assuming they have at least 2 products (Hint: Look at the HAVING operator)

SELECT Suppliers.SupplierName, AVG(Products.Price) FROM Suppliers 
JOIN Products ON(Suppliers.SupplierID = Products.SupplierID) 
JOIN OrderDetails ON(OrderDetails.ProductID = Products.ProductID)
GROUP BY Suppliers.SupplierID  HAVING COUNT(OrderDetails.ProductID) > 2
ORDER BY AVG(Products.Price) DESC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment