GQ / lab logES / EN
← Back to the log

2025

SQL Server sales dashboard with monthly forecasting

A stored procedure that builds a month-by-year sales table, and a Python script that forecasts the next month with linear regression on the previous 5 months.

SQL Server sales dashboard with monthly forecasting

Problem

Roll up transactional sales into a monthly table and estimate the next month.

Data

The course `Ventas2` sales database (SQL Server, 2004–2009). `data/TableroVentas.csv` is the table the stored procedure produces.

Method

A T-SQL stored procedure with transactions and error handling, a monthly pivot, a pyodbc connection and linear regression with scikit-learn.

Result

A dashboard regenerated by a single procedure, plus an on-demand monthly forecast.

Stack

  • SQL Server
  • T-SQL
  • Python
  • pyodbc
  • scikit-learn

Context

Course: Relational Databases · 2025

View the code on GitHub ↗