Skip to content

donn-chadh/northwind_SQL_project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Northwind Trading Analysis

SQL + Pyhton project using CTEs, window functions, and aggregatied queries on the Northwind database.

Database

SQLite (Northwind) Tables: Customers, Orders, OrderDetails, Products, Employees, Shippers, Suppliers, Categories.

Queries - found in queries folder

Each query is a .sql file. There questions/analysis below are implemented.

  1. Customer revenue ranking - DENSE_RANK() by total spend
  2. Daily running total - SUM() OVER(ORDER BY OrderDate)
  3. Month on month revenue change - LAG() with difference
  4. Top 3 products per category - ROW_NUMBER() PARTITION BY
  5. Employee sales vs company average - AVG() OVER()
  6. Employee sales rank - RANK()
  7. Customer order frequency rank - DENSE_RANK()
  8. First and last order per customer - MIN/MAX OVER(PARTITION BY)
  9. Product revenue rank within category - RANK() OVER(PARTITION BY)
  10. Unordered products - LEFT JOIN with IS NULL

Run all queries with python (SQLalchemy engine)

ERD table diagram

Northwind_ERD

Tech

  • SQLite
  • Python (pandas, sqlalchemy)
  • SQL (window functions, CTEs, joins)

About

An SQL analysis of the Northwind database to identify top-performing customers and products using CTEs and Window Functions. Includes a complete Entity Relationship Diagram (ERD) to model the database schema.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors