{"id":20177361,"url":"https://github.com/saba-gul/walmart-sales-analysis","last_synced_at":"2026-03-06T19:05:15.716Z","repository":{"id":249921075,"uuid":"832957692","full_name":"Saba-Gul/Walmart-Sales-Analysis","owner":"Saba-Gul","description":"This project involves analyzing Walmart sales data to gain insights into various aspects of the business, such as sales trends, product performance, customer demographics, and more.","archived":false,"fork":false,"pushed_at":"2024-07-24T05:07:50.000Z","size":345,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-03T05:26:42.585Z","etag":null,"topics":["business-analytics","business-intelligence","exploratory-data-analysis","powerbi","query-language","retail-ecomm","sales","sql","walmart"],"latest_commit_sha":null,"homepage":"","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/Saba-Gul.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-07-24T04:40:45.000Z","updated_at":"2024-07-24T05:10:25.000Z","dependencies_parsed_at":"2024-07-24T06:25:49.260Z","dependency_job_id":"11df642d-028f-4aa6-8fa6-a16df59d5fb3","html_url":"https://github.com/Saba-Gul/Walmart-Sales-Analysis","commit_stats":null,"previous_names":["saba-gul/walmart-sales-analysis"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Saba-Gul/Walmart-Sales-Analysis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saba-Gul%2FWalmart-Sales-Analysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saba-Gul%2FWalmart-Sales-Analysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saba-Gul%2FWalmart-Sales-Analysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saba-Gul%2FWalmart-Sales-Analysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Saba-Gul","download_url":"https://codeload.github.com/Saba-Gul/Walmart-Sales-Analysis/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saba-Gul%2FWalmart-Sales-Analysis/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30192410,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T18:54:55.862Z","status":"ssl_error","status_checked_at":"2026-03-06T18:53:04.013Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["business-analytics","business-intelligence","exploratory-data-analysis","powerbi","query-language","retail-ecomm","sales","sql","walmart"],"created_at":"2024-11-14T02:15:23.421Z","updated_at":"2026-03-06T19:05:15.696Z","avatar_url":"https://github.com/Saba-Gul.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Walmart Sales Data Analysis\n\n## About\n\nWe are analyzing Walmart's sales data to identify high-performing branches and products, analyze the sales patterns of various products, and understand customer behavior. The primary objective is to enhance and optimize sales strategies. The dataset utilized in this project is sourced from the Kaggle Walmart Sales Forecasting Competition.\n\n![Walmart Sales Data](walmart.jpeg)\n\n## Purposes of the Project\n\nThe main goal of this project is to gain insights from Walmart's sales data, exploring various factors that influence sales across different branches. This analysis aims to:\n\n- Identify high-performing branches and products.\n- Analyze sales patterns and trends.\n- Understand customer behavior and preferences.\n- Optimize sales strategies based on data-driven insights.\n\n## About Data\n\nThis project's data was obtained from the [Kaggle Walmart Sales Forecasting Competition](https://www.kaggle.com/datasets/yasserh/walmart-dataset)\n and encompasses sales transactions from three Walmart branches situated in Mandalay, Yangon, and Naypyitaw. The dataset contains 17 columns and 1000 rows with information on sales transactions, including:\n\n- Transaction date\n- Product details\n- Sales amounts\n- Customer information\n- Branch details\n\n## Business Questions and SQL Queries\n\n### Generic Questions\n\n1. **How many distinct cities are present in the dataset?**\n   ```sql\n   SELECT DISTINCT city\n   FROM walmartsales;\n   ```\n\n2. **In which city is each branch situated?**\n   ```sql\n   SELECT DISTINCT city, branch\n   FROM walmartsales;\n   ```\n\n### Product Analysis\n\n1. **How many distinct product lines are there in the dataset?**\n   ```sql\n   SELECT DISTINCT COUNT(DISTINCT product_line) AS num_of_products\n   FROM walmartsales;\n   ```\n\n2. **What is the most common payment method?**\n   ```sql\n   SELECT payment_method, COUNT(payment_method) AS common_payment_method\n   FROM walmartsales\n   GROUP BY payment_method\n   ORDER BY common_payment_method DESC;\n   ```\n\n3. **What is the most selling product line?**\n   ```sql\n   SELECT product_line, COUNT(product_line) AS cnt_product_line\n   FROM walmartsales\n   GROUP BY product_line\n   ORDER BY cnt_product_line DESC;\n   ```\n\n4. **What is the total revenue by month?**\n   ```sql\n   SELECT month_name, SUM(total) AS revenue\n   FROM walmartsales\n   GROUP BY month_name\n   ORDER BY revenue DESC;\n   ```\n\n5. **Which month recorded the highest Cost of Goods Sold (COGS)?**\n   ```sql\n   SELECT month_name, SUM(cogs) AS highest_cogs\n   FROM walmartsales\n   GROUP BY month_name\n   ORDER BY highest_cogs DESC\n   LIMIT 1;\n   ```\n\n6. **Which product line generated the highest revenue?**\n   ```sql\n   SELECT product_line, SUM(total) AS total_revenue\n   FROM walmartsales\n   GROUP BY product_line\n   ORDER BY total_revenue DESC\n   LIMIT 1;\n   ```\n\n7. **Which city has the highest revenue?**\n   ```sql\n   SELECT city, SUM(total) AS revenue\n   FROM walmartsales\n   GROUP BY city\n   ORDER BY revenue DESC\n   LIMIT 1;\n   ```\n\n8. **Which product line incurred the highest VAT?**\n   ```sql\n   SELECT product_line, SUM(VAT) AS highest_vat\n   FROM walmartsales\n   GROUP BY product_line\n   ORDER BY highest_vat DESC\n   LIMIT 1;\n   ```\n\n9. **Retrieve each product line and add a column `product_category`, indicating 'Good' or 'Bad,' based on whether its sales are above the average.**\n   ```sql\n   WITH ProductSales AS (\n       SELECT product_line, SUM(total) AS total_sales\n       FROM walmartsales\n       GROUP BY product_line\n   ),\n   AverageSales AS (\n       SELECT AVG(total_sales) AS avg_sales\n       FROM ProductSales\n   )\n   SELECT product_line, \n          CASE \n              WHEN total_sales \u003e (SELECT avg_sales FROM AverageSales) THEN 'Good'\n              ELSE 'Bad'\n          END AS product_category\n   FROM ProductSales;\n   ```\n\n10. **Which branch sold more products than the average product sold?**\n    ```sql\n    WITH AverageProducts AS (\n        SELECT AVG(total_quantity) AS avg_quantity\n        FROM (\n            SELECT SUM(quantity) AS total_quantity\n            FROM walmartsales\n            GROUP BY branch\n        ) AS BranchTotals\n    )\n    SELECT branch, SUM(quantity) AS total_quantity\n    FROM walmartsales\n    GROUP BY branch\n    HAVING SUM(quantity) \u003e (\n        SELECT avg_quantity\n        FROM AverageProducts\n    );\n    ```\n\n11. **What is the most common product line by gender?**\n    ```sql\n    SELECT gender, product_line, COUNT(product_line) AS popular_product\n    FROM walmartsales\n    GROUP BY product_line, gender\n    ORDER BY popular_product DESC;\n    ```\n\n12. **What is the average rating of each product line?**\n    ```sql\n    SELECT product_line, AVG(rating) AS avg_rating\n    FROM walmartsales\n    GROUP BY product_line\n    ORDER BY avg_rating DESC;\n    ```\n\n### Sales Analysis\n\n1. **Number of sales made in each time of the day per weekday.**\n   ```sql\n   SELECT time_of_day, day_name, COUNT(invoice_id) AS num_sales\n   FROM walmartsales\n   GROUP BY time_of_day, day_name\n   ORDER BY day_name, time_of_day;\n   ```\n\n2. **Identify the customer type that generates the highest revenue.**\n   ```sql\n   SELECT customer_type, SUM(total) AS revenue_per_customer_type\n   FROM walmartsales\n   GROUP BY customer_type\n   ORDER BY revenue_per_customer_type DESC;\n   ```\n\n3. **Which city has the largest tax percent/ VAT (Value Added Tax)?**\n   ```sql\n   SELECT city, ROUND(AVG(VAT), 2) AS vat_per_city\n   FROM walmartsales\n   GROUP BY city\n   ORDER BY vat_per_city DESC;\n   ```\n\n4. **Which customer type pays the most VAT?**\n   ```sql\n   SELECT customer_type, AVG(VAT) AS vat_customer_type\n   FROM walmartsales\n   GROUP BY customer_type\n   ORDER BY vat_customer_type DESC;\n   ```\n\n### Customer Analysis\n\n1. **How many unique customer types does the data have?**\n   ```sql\n   SELECT DISTINCT customer_type\n   FROM walmartsales;\n   ```\n\n2. **How many unique payment methods does the data have?**\n   ```sql\n   SELECT DISTINCT payment_method\n   FROM walmartsales;\n   ```\n\n3. **Which is the most common customer type?**\n   ```sql\n   SELECT customer_type, COUNT(*) AS cnt_customer_type\n   FROM walmartsales\n   GROUP BY customer_type;\n   ```\n\n4. **Which customer type buys the most?**\n   ```sql\n   SELECT customer_type, SUM(total) AS revenue_per_cust_type\n   FROM walmartsales\n   GROUP BY customer_type\n   ORDER BY revenue_per_cust_type DESC;\n   ```\n\n5. **What is the gender of most of the customers?**\n   ```sql\n   SELECT gender, COUNT(*) AS gender_dist\n   FROM walmartsales\n   GROUP BY gender\n   ORDER BY gender_dist DESC;\n   ```\n\n6. **What is the gender distribution per branch?**\n   ```sql\n   SELECT branch, gender, COUNT(gender) AS gender_dis\n   FROM walmartsales\n   GROUP BY gender, branch\n   ORDER BY branch;\n   ```\n\n7. **Which time of the day do customers give the most ratings?**\n   ```sql\n   SELECT time_of_day, COUNT(rating) AS rat_cnt\n   FROM walmartsales\n   GROUP BY time_of_day\n   ORDER BY rat_cnt DESC;\n   ```\n\n8. **Which time of the day do customers give the most ratings per branch?**\n   ```sql\n   WITH RatingsCount AS (\n       SELECT time_of_day, branch, COUNT(rating) AS total_ratings\n       FROM walmartsales\n       GROUP BY time_of_day, branch\n   ),\n   RankedRatings AS (\n       SELECT time_of_day, branch, total_ratings, ROW_NUMBER() OVER(PARTITION BY branch ORDER BY total_ratings DESC) AS rn\n       FROM RatingsCount\n   )\n   SELECT time_of_day, branch, total_ratings\n   FROM RankedRatings\n   WHERE rn = 1;\n   ```\n\n9. **Which day of the week has the best average ratings?**\n   ```sql\n   SELECT day_name, AVG(rating) AS avg_ratings\n   FROM walmartsales\n   GROUP BY day_name\n   ORDER BY avg_ratings DESC;\n   ```\n\n10. **Which day of the week has the best average ratings per branch?**\n    ```sql\n    WITH DailyAvgRatings AS (\n        SELECT branch, day_name, AVG(rating) AS avg_ratings\n        FROM walmartsales\n        GROUP BY day_name, branch\n    ),\n    RankedDays AS (\n        SELECT branch, day_name, avg_ratings, ROW_NUMBER() OVER(PARTITION BY branch ORDER BY avg_ratings DESC) AS rn\n        FROM DailyAvgRatings\n    )\n    SELECT branch, day_name, avg_ratings\n    FROM RankedDays\n    WHERE rn = 1;\n    ```\n\n## Revenue and Profit Calculations\n\n1. **Calculate total revenue:**\n   ```sql\n   SELECT SUM(total) AS total_revenue\n   FROM walmartsales;\n   ```\n\n2. **Calculate total profit:**\n   ```sql\n   SELECT SUM(profit) AS total_profit\n   FROM walmartsales;\n   ```\n\n## Data Visualization\n\n**Note:** For data visualization, we have used PowerBI to visualize sales patterns, revenue trends, and other insights.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaba-gul%2Fwalmart-sales-analysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaba-gul%2Fwalmart-sales-analysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaba-gul%2Fwalmart-sales-analysis/lists"}