Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQL + Python Business Analytics

Project Overview

This project demonstrates an end-to-end business analytics workflow using SQL, SQLite, Python, Pandas, and Matplotlib. The goal is to analyze retail sales data, answer business questions using SQL, and create visualizations that support data-driven decision-making.

The project follows a real-world analytics workflow:

  • Import retail sales data into a SQLite database.
  • Analyze the data using SQL queries.
  • Load SQL query results into Python with Pandas.
  • Create visualizations using Matplotlib.
  • Generate business insights and recommendations.

Project Highlights

  • Analyzed approximately 10,000 retail sales records.
  • Performed business analysis using SQL and SQLite.
  • Processed and analyzed data with Pandas.
  • Created visualizations using Matplotlib.
  • Exported analytical reports as CSV files.
  • Organized SQL queries into reusable SQL scripts.

Objectives

  • Practice SQL for business analysis.
  • Learn how SQL and Python work together.
  • Perform exploratory data analysis (EDA).
  • Build a GitHub-ready portfolio project.
  • Present business insights through data visualization.

Features

  • Import and analyze sales data using SQLite.
  • Execute SQL queries for business reporting.
  • Integrate SQL results into Python.
  • Analyze data using Pandas.
  • Create professional visualizations using Matplotlib.
  • Export analysis results as CSV files.
  • Generate business recommendations from data.

Technologies Used

  • Python
  • SQLite
  • SQL
  • Pandas
  • Matplotlib
  • Jupyter Notebook
  • Git
  • GitHub

Dataset

Dataset: Sample Superstore

The dataset contains retail sales transactions including:

  • Orders
  • Customers
  • Products
  • Categories
  • Regions
  • Sales
  • Profit
  • Discounts
  • Quantity

Project Structure

sql-python-business-analytics/
│
├── data/
├── database/
├── images/
├── notebooks/
├── outputs/
├── sql/
│   ├── 01_database_setup.sql
│   └── 02_business_analysis.sql
├── README.md
├── requirements.txt
└── .gitignore

Business Questions Answered

This project answers important business questions such as:

  • Which category generates the highest sales?
  • Which region performs the best?
  • Which customer segment contributes the most revenue?
  • Who are the top-performing customers?
  • Which products generate losses?
  • How do sales and profits change over time?

Analysis Performed

KPI Analysis

  • Total Sales
  • Total Profit
  • Total Orders
  • Average Order Value
  • Profit Margin

Customer Segment Analysis

  • Sales by Segment
  • Profit by Segment
  • Profit Margin by Segment

Category Analysis

  • Sales by Category
  • Profit by Category
  • Average Sale
  • High Sales Categories

Regional Analysis

  • Sales by Region
  • Regional Profitability
  • Technology Sales by Region

Customer Analysis

  • Loyal Customers
  • Top Sales Customers
  • Customer Profit Analysis

Product Analysis

  • Top Sales Products
  • Product Profit Analysis
  • Loss-Making Products

Time Analysis

  • Monthly Sales Trends
  • Yearly Sales Trends

Visualizations

Sales by Category

Category Sales

Sales by Region

Region Sales

Sales by Customer Segment

Segment Sales

Top 10 Customers by Sales

Top Customers


Key Business Insights

  • Technology generated the highest sales and overall profit.
  • Furniture recorded high sales but the lowest profit margin.
  • The West region achieved the highest sales performance.
  • The Consumer segment generated the highest overall revenue.
  • Several products and customers generated negative profits due to heavy discounting.
  • Sales performance varied across regions, highlighting opportunities for targeted business strategies.

Business Recommendations

  • Continue investing in high-performing Technology products.
  • Improve Furniture profitability by reviewing pricing and discount strategies.
  • Increase marketing efforts in lower-performing regions.
  • Review pricing and discount policies for loss-making customers and products.
  • Monitor monthly sales trends to support inventory and sales planning.

Skills Demonstrated

SQL

  • SELECT
  • WHERE
  • GROUP BY
  • ORDER BY
  • HAVING
  • COUNT()
  • SUM()
  • AVG()
  • ROUND()
  • LIMIT
  • SQLite Functions

Python

  • sqlite3
  • Pandas
  • DataFrames
  • SQL Integration
  • CSV Export
  • Matplotlib Visualization

Business Analysis

  • KPI Reporting
  • Customer Analysis
  • Product Analysis
  • Regional Analysis
  • Trend Analysis
  • Business Recommendations

Learning Outcomes

Through this project, I learned how to:

  • Store data in a SQLite database.
  • Write SQL queries for business analysis.
  • Connect Python with SQLite.
  • Load SQL query results into Pandas.
  • Create business visualizations using Matplotlib.
  • Communicate insights through data analysis and recommendations.
  • Organize and publish a professional analytics project using Git and GitHub.

Future Improvements

  • Build an interactive dashboard using Power BI.
  • Explore advanced SQL concepts such as Joins, CTEs, and Window Functions.
  • Automate report generation.
  • Extend the analysis with predictive analytics.
  • Deploy the project as an interactive analytics application.

How to Run

  1. Clone this repository.
git clone https://github.com/lena-basheer/sql-python-business-analytics.git
  1. Navigate to the project folder.
cd sql-python-business-analytics
  1. Create and activate a virtual environment.

  2. Install the required packages:

pip install -r requirements.txt
  1. Launch Jupyter Notebook:
jupyter notebook
  1. Open:
notebooks/analysis.ipynb
  1. Run all cells to reproduce the analysis and visualizations.

Author

Lena B

Aspiring Data Analyst | SQL | Python | Excel | Power BI | Pandas | SQLite | Matplotlib

About

End-to-end SQL and Python retail analytics project analyzing 10K+ records to uncover customer, product, category, and regional sales insights.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages