{"id":26897215,"url":"https://github.com/merrill007/analyzing-sales-and-customer-data-using-sql","last_synced_at":"2026-01-11T16:03:43.984Z","repository":{"id":264479153,"uuid":"893485690","full_name":"Merrill007/Analyzing-Sales-and-Customer-Data-using-SQL","owner":"Merrill007","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-24T15:45:52.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-24T16:35:30.406Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"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/Merrill007.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}},"created_at":"2024-11-24T15:15:31.000Z","updated_at":"2024-11-24T15:45:56.000Z","dependencies_parsed_at":"2024-11-24T16:45:57.252Z","dependency_job_id":null,"html_url":"https://github.com/Merrill007/Analyzing-Sales-and-Customer-Data-using-SQL","commit_stats":null,"previous_names":["merrill007/analyzing-sales-and-customer-data-using-sql"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Merrill007%2FAnalyzing-Sales-and-Customer-Data-using-SQL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Merrill007%2FAnalyzing-Sales-and-Customer-Data-using-SQL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Merrill007%2FAnalyzing-Sales-and-Customer-Data-using-SQL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Merrill007%2FAnalyzing-Sales-and-Customer-Data-using-SQL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Merrill007","download_url":"https://codeload.github.com/Merrill007/Analyzing-Sales-and-Customer-Data-using-SQL/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246586087,"owners_count":20801026,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2025-04-01T04:41:54.203Z","updated_at":"2026-01-11T16:03:43.977Z","avatar_url":"https://github.com/Merrill007.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Analyzing-Sales-and-Customer-Data-using-SQL\n\n## Table of Contents\n1. [Introduction](#introduction)\n2. [Objective](#objective)\n3. [Dataset and Tools](#dataset-and-tools)\n4. [SQL Queries](#SQL-Queries)\n5. [Insights and Findings](#insights-and-findings)\n6. [Conclusions](#conclusions)\n\n---\n\n## Introduction\n\nThis project involves analyzing the **AdvantureWorks2019** database to extract insights about sales, customer behaviour, product performance and supplier efficiency. The project uses SQL to query and analyze data, uncovering key patterns, and actionable insights.\n\n--- \n\n## Objective\n\nThe goal of this project are:\n1. To identify top customers by revenue.\n2. To analyze product performance and popularity.\n3. To evaluate sales trend over time.\n4. To assess supplier performance and reliability.\n\n---\n\n## Dataset and Tools\n\nThe project uses the **AdvantureWorks2019** database.  It contains data related to a ficitious company taht sells bicycles and cycling accessories.\n\n**Data Dictionary**\n- **Sales.SalesOrderHeader**: This table contains header information for sales orders, including order ID, order date, customer ID, salesperson ID, and shipping information.\n- **Sales.Customer**: This table contains information about customers, including customer ID, name, geographic location, demographic information, and contact information.\n- **Sales.SalesPerson**: This table contains information about salespeople, including salesperson ID, name, and demographic information.\n- **Sales.SalesTerritory**: This table contains information about sales territories, including territory ID, name, and geographic information.\n- **Production.Product**: This table contains information about products, including product ID, name, category, cost, and price.\n- **Sales.SalesOrderDetail**: This table contains detailed information about sales orders, including order ID, product ID, quantity, unit price, and discount.\n- **Purchasing.PurchaseOrderHeade**r: This table contains header information for purchase orders, including order ID, order date, vendor ID, and shipping information.\n- **Purchasing.Vendor**: This table contains information about vendors, including vendor ID, name, and contact information.\n- **Purchasing.PurchaseOrderDetail**: This table contains detailed information about purchase orders, including order ID, product ID, quantity, unit price, and discount.\n- **Production.WorkOrder**: This table contains information about production work orders, including work order ID, product ID, start and end dates, and status.\n\n![image](https://github.com/user-attachments/assets/c31029cd-67ab-4e34-8880-3b5747618883)\\\n\n---\n\n## SQL Queries\n\n1. **What are the most popular products among customers?**\n\n```sql\nSELECT TOP 10 Product.Name, SUM(SalesOrderDetail.OrderQty) AS TotalQuantitySold\nFROM Production.Product AS Product\nJOIN Sales.SalesOrderDetail AS SalesOrderDetail \nON Product.ProductID = SalesOrderDetail.ProductID\nGROUP BY Product.Name\nORDER BY TotalQuantitySold DESC;\n```\n\n2. WHAT ARE THE MOST PROFITABLE PRODUCTS?\n\n```sql\nSELECT TOP 10\n    p.Name, \n    SUM(od.LineTotal) AS Total_Sales,\n    SUM(od.LineTotal - (od.OrderQty * p.StandardCost)) AS TotalProfit,\n    (SUM(od.LineTotal - (od.OrderQty * p.StandardCost)) / SUM(OD.LineTotal)) * 100 AS ProfitMargin\nFROM Production.Product AS P\nJOIN Sales.SalesOrderDetail od \nON p.ProductID = od.ProductID\nGROUP BY p.Name\nORDER BY ProfitMargin DESC;\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmerrill007%2Fanalyzing-sales-and-customer-data-using-sql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmerrill007%2Fanalyzing-sales-and-customer-data-using-sql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmerrill007%2Fanalyzing-sales-and-customer-data-using-sql/lists"}