Problem: A startup business, called “Startup Helper”, is creating a database to help manage customer records and product inventory data. They need your help creating the MySQL statements to answer their business questions.
Section 1: MySQL Basics
Task: Create a SQL query to create a database called “StartupHelper”.
Solution: CREATE DATABASE StartupHelper;
Section 2: Data Selection
Task: Create a SQL query to select all the customer data from the “Customers” table.
Solution: SELECT * from Customers;
Section 3: Transactions
Task: Create a SQL query to start a transaction to update the inventory table.
Solution: START TRANSACTION;
Section 4: Joins
Task: Create a SQL query to join the customer table and the product inventory table.
Solution: SELECT * from Customers INNER JOIN ProductInventory ON Customers.CustomerID = ProductInventory.CustomerID;
Section 5: Aggregate Functions
Task: Create a SQL query to calculate the total number of customers in the “Customers” table.
Solution: SELECT COUNT(*) FROM Customers;
Section 6: Subqueries
Task: Create a SQL query to select the customer details of those who are ordering more than 10 products.
Solution: SELECT * FROM Customers WHERE CustomerID IN (SELECT CustomerID FROM ProductInventory GROUP BY CustomerID HAVING COUNT(*) > 10);
Loading...