Skip to content

Repository files navigation

Sales Optimization SQL — Business Intelligence Analysis

BI / RevOps portfolio project · SQL · Sales performance · Profitability Status: Finished A set of analytical SQL queries over a B2B sales dataset that answer the questions a sales leader actually asks: which regions are most profitable, who are the top performers, and where is margin leaking.

🇬🇧 English version first. · 🇪🇸 La versión en español está más abajoir a Español.

Ficha del proyecto Stack Domain License: MIT

SQL profitability analysis running: revenue and profit by region with derived margin

Open the live demo


The problem this solves

Raw sales data is just rows until someone asks the right questions of it. This project demonstrates the analytical SQL that turns a sales table into decisions: profitability by region, top performers, customer concentration, low-margin products and the discount-vs-profit trade-off. These are the exact queries a BI analyst writes to brief a commercial team.

It showcases SQL fluency for analytics — aggregation, grouping, ranking and derived business metrics — the daily language of Business Intelligence.


The analysis — 5 queries

# Question SQL technique
1 Total revenue & profit margin by region SUM, GROUP BY, derived margin %
2 Top 5 salespeople by revenue GROUP BY, ORDER BY, LIMIT
3 Customer distribution by product category & type multi-column GROUP BY
4 Products / segments with low margin filtering on derived metrics
5 Discounts vs profit relationship comparative aggregation

The dataset (sales_data.csv, ~10,000 rows) is generated by generate_data.py; the analysis lives in sales_analysis.sql, ready to run on any SQL engine.


Tech stack

Layer Technology
Analysis SQL (ANSI — portable across PostgreSQL / SQLite / MySQL)
Data generation Python · Pandas
Visualization Power BI · Tableau (downstream)

Getting started

git clone https://github.com/mindset-code/project-sales-optimization-sql.git
cd project-sales-optimization-sql
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt

python generate_data.py     # creates sales_data.csv (~10,000 rows)
# then load sales_data.csv into your SQL engine and run sales_analysis.sql

Repository structure

project-sales-optimization-sql/
├── sales_analysis.sql   # 5 analytical queries
├── generate_data.py     # synthetic sales dataset generator
├── requirements.txt     # Python dependencies
├── LICENSE              # MIT
└── README.md

License & contact

Released under the MIT License.


🇪🇸 Español

Sales Optimization SQL — Análisis de Business Intelligence

Proyecto de portafolio de BI / RevOps · SQL · Rendimiento de ventas · Rentabilidad Estado: Terminado Conjunto de consultas SQL analíticas sobre un dataset de ventas B2B que responden las preguntas que un líder comercial realmente hace: qué regiones son más rentables, quiénes son los top performers y dónde se fuga el margen.

🇪🇸 Traducción al español. La versión en inglés está al inicio → ir a English.


El problema que resuelve

Los datos de ventas en bruto son solo filas hasta que alguien les hace las preguntas correctas. Este proyecto demuestra el SQL analítico que convierte una tabla de ventas en decisiones: rentabilidad por región, top performers, concentración de clientes, productos de bajo margen y el trade-off descuento-vs-beneficio. Son exactamente las consultas que un analista de BI escribe para informar a un equipo comercial.

Muestra fluidez en SQL para analítica — agregación, agrupación, ranking y métricas de negocio derivadas — el lenguaje diario del Business Intelligence.


El análisis — 5 consultas

# Pregunta Técnica SQL
1 Revenue total y margen de beneficio por región SUM, GROUP BY, % margen derivado
2 Top 5 vendedores por revenue GROUP BY, ORDER BY, LIMIT
3 Distribución de clientes por categoría y tipo de producto GROUP BY multicolumna
4 Productos / segmentos con bajo margen filtrado sobre métricas derivadas
5 Relación descuentos vs beneficio agregación comparativa

El dataset (sales_data.csv, ~10.000 filas) lo genera generate_data.py; el análisis vive en sales_analysis.sql, listo para ejecutar en cualquier motor SQL.


Stack técnico

Capa Tecnología
Análisis SQL (ANSI — portable entre PostgreSQL / SQLite / MySQL)
Generación de datos Python · Pandas
Visualización Power BI · Tableau (downstream)

Cómo empezar

git clone https://github.com/mindset-code/project-sales-optimization-sql.git
cd project-sales-optimization-sql
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt

python generate_data.py     # crea sales_data.csv (~10.000 filas)
# luego carga sales_data.csv en tu motor SQL y ejecuta sales_analysis.sql

Estructura del repositorio

project-sales-optimization-sql/
├── sales_analysis.sql   # 5 consultas analíticas
├── generate_data.py     # generador de dataset de ventas sintético
├── requirements.txt     # dependencias Python
├── LICENSE              # MIT
└── README.md

Licencia y contacto

Publicado bajo la Licencia MIT.


Mindset & Code · asesoría fiscal y tecnológica · mindset-code.com

About

Diez mil líneas de venta cortadas por producto, región y descuento. SQL + Python + Power BI.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages