Introduction

This SQL project involves analyzing the sales and customer data of H+ Sport, a fictitious company that sells nutritional products and active lifestyle clothing. The focus is on the mineral water department, with the goal of improving sales and maintaining data accuracy. The project showcases a variety of SQL queries designed to manage, analyze, and interpret data, making it a valuable addition to a data science portfolio.

Company Background

H+ Sport is dedicated to creating eco-friendly, high-quality, nutrient-rich nutritional products that enhance active lifestyles. The company also offers functional, stylish, comfortable, and durable activewear. H+ Sport was founded in 2006 by Henry Tool and sells products like supplements, energy bars, rehydration solutions, and mineral water. The company’s mineral water comes in six flavors: strawberry, raspberry, peach, orange, lemon lime, and blueberry.

Database Description

The database used for this project is named hplussport and contains five tables:

  • Customer: Stores customer information.
  • OrderItem: Contains details of individual items in each order.
  • Orders: Records customer orders.
  • Product: Lists the products available for sale.
  • Salesperson: Contains information about salespeople.

SQL Queries and Analysis

1. Inserting a New Product

Objective: Add a new grape flavor to the product table.

INSERT INTO Product (
    ProductID,
    ProductCode,
    ProductName,
    Size,
    Variety,
    Price,
    Status
)
VALUES (
    17,
    'MWPRA20',
    'Mineral Water',
    20,
    'Grape',
    '1.79',
    'ACTIVE'
);

2. Sorting Orders by Date

Objective: Sort orders by their creation date in descending order.

SELECT *
FROM Orders
ORDER BY CreationDate DESC;

3. Handling Null Values in Customer Table

Objective: Identify and remove entries with null values in essential columns.

SELECT *
FROM Customer
WHERE FirstName IS NULL OR LastName IS NULL OR Email IS NULL OR Phone IS NULL;

SELECT FirstName, LastName, Email, Phone
FROM Customer
WHERE Email IS NOT NULL AND Phone IS NOT NULL;

4. Analyzing Sales by Month and Year

Objective: Determine the total orders, quantities, and amount by month and year.

SELECT
    MONTHNAME(CreationDate) AS MonthName,
    YEAR(CreationDate) AS OrderYear,
    MONTH(CreationDate) AS OrderMonth,
    COUNT(Orders.OrderID) AS TotalOrders,
    SUM(Quantity) AS TotalQuantity,
    SUM(TotalDue) AS TotalAmount
FROM Orders
LEFT OUTER JOIN OrderItem
ON Orders.OrderID = OrderItem.OrderID
GROUP BY MonthName, OrderYear, OrderMonth
ORDER BY OrderYear, OrderMonth;

5. Identifying Discontinued Products

Objective: Find products that are no longer active.

SELECT *
FROM Product
WHERE Status = "DISCONTINUED";

6. Top Products and Sizes Sold

Objective: Determine the top product sizes sold and the top three items based on quantity.

SELECT Size, SUM(Quantity) AS TotalQuantity
FROM OrderItem
LEFT OUTER JOIN Product
ON OrderItem.ProductID = Product.ProductID
GROUP BY Size
ORDER BY TotalQuantity DESC;

SELECT Variety, Size, SUM(Quantity) AS TotalQuantity
FROM OrderItem
LEFT OUTER JOIN Product
ON OrderItem.ProductID = Product.ProductID
GROUP BY Product.ProductID
ORDER BY TotalQuantity DESC
LIMIT 3;

7. Identifying Top Customers and Salespeople

Objective: Identify the top customers and salespeople who made no sales.

SELECT FirstName, LastName, COUNT(DISTINCT Orders.OrderID) AS TotalOrders, SUM(Quantity) AS TotalQuantity, SUM(TotalDue) AS TotalAmount
FROM Orders
LEFT OUTER JOIN OrderItem
ON Orders.OrderID = OrderItem.OrderID
LEFT OUTER JOIN Customer
ON Orders.CustomerID = Customer.CustomerID
GROUP BY Customer.CustomerID
ORDER BY TotalAmount DESC;

SELECT Salesperson.SalespersonID, FirstName, LastName
FROM Salesperson
LEFT OUTER JOIN Orders
ON Salesperson.SalespersonID = Orders.SalespersonID 
WHERE Orders.SalespersonID IS NULL;

8. Calculating Repeat Customer Rate

Objective: Calculate the percentage of customers who made more than one purchase.

WITH Repeat_Customers AS (
  SELECT CustomerID AS Repeat_Cus
  FROM Orders
  GROUP BY CustomerID
  HAVING COUNT(OrderID) > 1
)
SELECT 
(COUNT(DISTINCT Repeat_Cus) / COUNT(DISTINCT CustomerID)) * 100 AS CustomerRepeatRate
FROM Orders
LEFT OUTER JOIN Repeat_Customers
ON Orders.CustomerID = Repeat_Customers.Repeat_Cus;

Conclusion

This SQL project provides comprehensive insights into H+ Sport’s customer and sales data, focusing on enhancing the mineral water department’s performance. By executing various SQL queries, the project highlights key data management and analysis skills, making it a valuable component of a data science portfolio.

Recommendations

  • Continue to monitor sales trends and customer behaviors.
  • Utilize the insights from the SQL queries to make data-driven decisions.
  • Expand the analysis to other departments for a holistic view of company performance.

2025

Sales Insights

Introduction This SQL project involves analyzing the sales and customer data of H+ Sport, a fictitious company that sells nutritional products and active lif...

Back to Top ↑

2023

The B.A.R.N. Framework

Introduction Writing about your projects is crucial to giving context for the work. Writing an impactful article requires a structured approach that captures...

Healthcare Insights

Introduction The project is to demonstrate the use of SQL to extract meaningful insights from a hospital database. This includes analysing patient demographi...

Design Basics

Your brain has two systems, a slow analytical side and a quick, instinctive “gut” side. For the most part, the instinctual side is lazy, conserving its energ...

Part 1: Color Theory

“Color does not add a pleasant quality to design—it reinforces it.” — Pierre Bonnard

Part 3: Color Theory

Tips for Designing a Color Palette In the first two sections of this book, Color Limitations and Color and Emotions, we looked at some interesting facts abou...

Part 2: Color Theory

Color and Emotions Mention Thanksgiving to any American and they will paint a picture in their head with gold, orange, red, and brown hues. It will also like...

Collaborate the Game

Background In 2019 I was awarded a Department of Education SBIR grant to build an educational board game about collaboration. Though the game would eventuall...

Shuffling Cards

To see a preview of this project go to Shuffling Cards on Codespaces and select the index.html file and then go live on the status bar.

Alika’s Treehouse

Alika’s Treehouse Background This project won the Capital One Women In Tech Demo Day. The challenge, “Help young women of color see themselves as a Computer ...

Part 1: How to win at a hackathon

Time and pressure can change almost anything from what it was into what it has become. Time will change, “Caterpillar into butterflies, sand into pearls...

Part 2: How to win at a hackathon

“You can’t connect the dots looking forward; you can only connect them looking backwards. So you have to trust that the dots will somehow connect in your ...

Accelerating your Career

Looking back on my career, there are a few things I wish I had done earlier to boost my career progression and enhance my marketability. In this article, I w...

Part 3: How to win at a hackathon

“No struggle, no success! The strongest thunder strikes often bring the heaviest rainfall! The weight of your fulfillment depends on how wide you cast you...

Back to Top ↑