This repository contains a comprehensive set of SQL scripts designed to build and analyze a data warehouse for business insights. It follows a structured approach, from database setup to dimensional modeling, and advanced analytical queries.
Creates the DataWarehouseAnalytics database and the gold schema. It sets up three core tables:
dim_customersdim_productsfact_sales
- Lists all tables and views in the database using
INFORMATION_SCHEMA.TABLES - Describes the structure of the
dim_customerstable usingINFORMATION_SCHEMA.COLUMNS
Explores dimension tables:
- Unique
countryvalues indim_customers - Unique combinations of
category,subcategory, andproduct_nameindim_products
Assesses date-related insights:
- Minimum and maximum
order_datevalues fromfact_sales - Age range of customers based on
birthdate
Calculates high-level metrics such as:
- Total sales, quantity, and orders
- Average selling price
- Number of unique products and active customers
- Business summary report via
UNION ALL
Groups and quantifies metrics:
- Customers by country and gender
- Products by category
- Average cost per category
- Revenue by product category and customer
- Distribution of sold items across countries
Identifies top and bottom performers using RANK(), TOP, and ROW_NUMBER():
- Top 5 revenue-generating products
- Bottom 5 worst-performing products
- Top 10 highest-spending customers
- Bottom 3 customers by number of orders
.
βββ 00_init_database.sql
βββ 01_database_exploration.sql
βββ 02_dimensions_exploration.sql
βββ 03_date_range_exploration.sql
βββ 04_measures_exploration.sql
βββ 05_magnitude_analysis.sql
βββ 06_ranking_analysis.sql
- Microsoft SQL Server
- Management tool (e.g., SSMS)
- CSV data