{"id":51303115,"url":"https://github.com/rakeshmen/sql-root-cause-analysis-sales-spike","last_synced_at":"2026-06-30T22:01:34.882Z","repository":{"id":322210424,"uuid":"1088558438","full_name":"rakeshmen/sql-root-cause-analysis-sales-spike","owner":"rakeshmen","description":"End-to-end SQL Server Root Cause Analysis (RCA) project uncovering the drivers behind a May 2025 sales spike. Features dimensional data modeling, realistic sales and pricing simulation, advanced SQL analytics, and insights on price impact. A powerful data analyst portfolio project showcasing SQL mastery and business insight.","archived":false,"fork":false,"pushed_at":"2025-11-03T06:47:54.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-03T08:24:12.441Z","etag":null,"topics":["anomaly-detection","diagnostics","diagnostics-analysis","ms-sql-server","root-cause-analysis","sql","sql-query","sql-server","trend-analysis"],"latest_commit_sha":null,"homepage":"","language":"TSQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rakeshmen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-03T06:13:36.000Z","updated_at":"2025-11-03T06:50:28.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/rakeshmen/sql-root-cause-analysis-sales-spike","commit_stats":null,"previous_names":["rakeshmen/sql-root-cause-analysis-sales-spike"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/rakeshmen/sql-root-cause-analysis-sales-spike","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rakeshmen%2Fsql-root-cause-analysis-sales-spike","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rakeshmen%2Fsql-root-cause-analysis-sales-spike/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rakeshmen%2Fsql-root-cause-analysis-sales-spike/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rakeshmen%2Fsql-root-cause-analysis-sales-spike/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rakeshmen","download_url":"https://codeload.github.com/rakeshmen/sql-root-cause-analysis-sales-spike/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rakeshmen%2Fsql-root-cause-analysis-sales-spike/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34984784,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-30T02:00:05.919Z","response_time":92,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anomaly-detection","diagnostics","diagnostics-analysis","ms-sql-server","root-cause-analysis","sql","sql-query","sql-server","trend-analysis"],"created_at":"2026-06-30T22:01:34.375Z","updated_at":"2026-06-30T22:01:34.877Z","avatar_url":"https://github.com/rakeshmen.png","language":"TSQL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Root Cause Analysis (RCA) Using SQL: Investigating Sales Spike in May 2025\n\n## Problem Statement\nIn May 2025, sales data showed a sudden spike. The business team suspected that product pricing changes and new product launches may have influenced this surge.  \nThis project demonstrates how a data analyst can use SQL-based Root Cause Analysis (RCA) to uncover the true drivers behind sales anomalies using realistic, structured, and referentially integrated data models.\n\n---\n\n## Objective\nThe goal of this simulation project is to perform hands-on Root Cause Analysis using SQL Server by:\n- Designing a normalized schema with referential integrity (Dimension and Fact tables).\n- Generating synthetic but realistic product, price, and sales data across 2025.\n- Detecting sales anomalies (spikes) and identifying causal factors (price drops, new product launches).\n- Showcasing analytical storytelling through data-driven insights using SQL.\n\n---\n\n## STAR Format Overview\n\n### Situation\nA retail business observed an unusual sales spike in May 2025. They wanted to understand if it was caused by internal business decisions (like pricing changes or product introductions) or external factors.\n\n### Task\nBuild a mini data warehouse schema and use SQL Root Cause Analysis to pinpoint what led to the spike.  \nThe analysis had to be replicable, auditable, and based on real-world data modeling practices (dimensional model with fact and dimension tables).\n\n### Action\n1. **Schema Design**\n   - Created schema `rca` with the following tables:\n     - `rca.dim_product`: Product master data.\n     - `rca.dim_date`: Calendar dimension (Jan–Dec 2025).\n     - `rca.dim_product_price`: Monthly price history of all products.\n     - `rca.fact_sales`: Transactional sales fact table capturing quantity and unit price.\n\n2. **Data Simulation**\n   - Added 3 base products (Jan–Apr) and 2 new products (May onward).\n   - Simulated monthly price changes and sales transactions (10–15 per month).\n   - Designed realistic May 2025 scenario: price drops and new product launches leading to a sales spike.\n\n3. **Root Cause Analysis Queries**\n   - Compared month-over-month sales volume and revenue growth.\n   - Correlated price changes with sales spike percentage.\n   - Identified products contributing most to the spike.\n   - Measured price elasticity using SQL aggregations.\n\n4. **Insights Delivered Using SQL**\n   - Used CTEs (Common Table Expressions), window functions, and joins to trace causality.\n   - Built trend views for easy visualization in BI tools like Power BI or Tableau.\n\n### Result\nThe SQL analysis revealed that:\n- Average product prices dropped by 15–20% in May 2025.\n- Two new products contributed 40% of total May revenue.\n- The sales spike was primarily driven by price reductions and new product launches, not seasonality.\n\nThis finding allowed the business to strategically plan future promotions and adjust inventory management based on data-driven insights.\n\n---\n\n## SQL Schema Overview\n\n```sql\nSchema: rca\n\nTables:\n1. dim_date(date_key, full_date, month_name, year)\n2. dim_product(product_id, product_name, category)\n3. dim_product_price(product_id, price_month, price)\n4. fact_sales(sale_id, sale_date, product_id, quantity, unit_price, total_amount)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frakeshmen%2Fsql-root-cause-analysis-sales-spike","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frakeshmen%2Fsql-root-cause-analysis-sales-spike","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frakeshmen%2Fsql-root-cause-analysis-sales-spike/lists"}