{"id":23511106,"url":"https://github.com/iankitnegi/sql_adhoc_analysis_project","last_synced_at":"2025-10-31T11:30:44.670Z","repository":{"id":243620248,"uuid":"812909068","full_name":"iankitnegi/SQL_AdHoc_Analysis_Project","owner":"iankitnegi","description":"Atliq Hardwares, a leading computer hardware producer in India with a global reach, seeks to enhance its data analytics team for better decision-making insights. Tony Sharma, the Data Analytics Director, is hiring junior analysts with strong tech and soft skills, using a SQL and code basics challenge to evaluate candidates.","archived":false,"fork":false,"pushed_at":"2024-07-05T09:43:54.000Z","size":1103,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-25T12:13:16.837Z","etag":null,"topics":["consumer","goods","mysql","powerbi","sql"],"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/iankitnegi.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-06-10T06:18:55.000Z","updated_at":"2024-07-05T09:43:58.000Z","dependencies_parsed_at":"2024-06-22T21:49:14.305Z","dependency_job_id":null,"html_url":"https://github.com/iankitnegi/SQL_AdHoc_Analysis_Project","commit_stats":null,"previous_names":["iankitnegi/mysql_consumer_goods_project","iankitnegi/mysql_adhoc_analysis_project"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iankitnegi%2FSQL_AdHoc_Analysis_Project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iankitnegi%2FSQL_AdHoc_Analysis_Project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iankitnegi%2FSQL_AdHoc_Analysis_Project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iankitnegi%2FSQL_AdHoc_Analysis_Project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iankitnegi","download_url":"https://codeload.github.com/iankitnegi/SQL_AdHoc_Analysis_Project/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239192790,"owners_count":19597757,"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":["consumer","goods","mysql","powerbi","sql"],"created_at":"2024-12-25T12:13:19.886Z","updated_at":"2025-10-31T11:30:44.626Z","avatar_url":"https://github.com/iankitnegi.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Problem Statement  \nAtliq Hardwares, a leading computer hardware manufacturer based in India with a global presence, is seeking to enhance its data analytics capabilities. The management has observed a lack of sufficient insights for making swift, data-driven decisions. To address this, they plan to expand their data analytics team by recruiting several junior data analysts. Tony Sharma, the Data Analytics Director, aims to find candidates proficient in both technical and interpersonal skills. To evaluate these abilities, he has organized a SQL challenge.\n\n## 1. ASK  \nDirector: Mr. Tony Sharma \n\n### Questions:  \n- Provide the list of markets in which customer \"Atliq Exclusive\" operates its business in the APAC region.\n- What is the percentage of unique product increase in 2021 vs. 2020? The final output contains these fields : unique_products_2020, unique_products_2021 \u0026 percentage_chg.\n- Provide a report with all the unique product counts for each segment and sort them in descending order of product counts? The final output contains 2 fields: segment \u0026 product_count.\n- Follow-up: Which segment had the most increase in unique products in 2021 vs 2020? The final output contains these fields: segment, product_count_2020, product_count_2021 \u0026 difference.\n- Get the products that have the highest and lowest manufacturing costs? The final output should contain these fields: product_code, product \u0026 manufacturing_cost.\n- Generate a report which contains the top 5 customers who received an average high pre_invoice_discount_pct for the fiscal year 2021 and in the Indian market. The final output contains these fields: customer_code, customer \u0026 average_discount_percentage.\n- Get the complete report of the Gross sales amount for the customer “Atliq Exclusive” for each month. This analysis helps to get an idea of low and high-performing months and take strategic decisions. The final report contains these columns: Month, Year \u0026 Gross sales Amount.\n- In which quarter of 2020, got the maximum total_sold_quantity? The final output contains these fields sorted by the total_sold_quantity, Quarter \u0026 total_sold_quantity.\n- Which channel helped to bring more gross sales in the fiscal year 2021 and the percentage of contribution? The final output contains these fields: channel, gross_sales_mln \u0026 percentage.\n- Get the Top 3 products in each division that have a high total_sold_quantity in the fiscal_year 2021? The final output contains these fields: division, product_code, product, total_sold_quantity \u0026 rank_order.\n\n\n## 2. PREPARE  \n### Data Storage:\n[Resume Project Challenge 04] The public dataset is completely available on the Code basis website platform where it stores and consolidates all available datasets for analysis. The specific individual datasets at hand can be obtained at this link below: https://codebasics.io/challenge/codebasics-resume-project-challenge  \n\n### Data Organized:\nThe dataset is taken from the AtliQ. Thanks to the AtliQ for providing datasets for public access which is a great learning asset - feel free to explore them here. This dataset contains only gdb023' (atliq_hardware_db) database and 1 text file (meta_data)\n\n\n## 3. PROCESS  \n### Tools Used:\n1. MySQL\n2. Power BI\n\n### Data Used:\ndim_customers, dim_product, fact_gross_price, fact_manufacturing_cost, fact_pre_invoice_deductions, fact_sales_monthly  \n\n### About Data:  \nThis file provides a comprehensive overview of the tables found in the 'gdb023' (atliq_hardware_db) database. It includes information for six main tables:\n\n1. dim_customer: contains customer-related data\n2. dim_product: contains product-related data\n3. fact_gross_price: contains gross price information for each product\n4. fact_manufacturing_cost: contains the cost incurred in the production of each product\n5. fact_pre_invoice_deductions: contains pre-invoice deductions information for each product\n6. fact_sales_monthly: contains monthly sales data for each product.\n\nColumn Description for dim_customer table:\n1. customer_code: The 'customer_code' column features unique identification codes for every customer in the dataset. These codes can be used to track a customer's sales history, demographic information, and other relevant details. For example, the codes could look like '70002017', '90005160', and '80007195' respectively.\n2. customer: The 'customer' column lists the names of customers, for example 'Atliq Exclusive', 'Flipkart', and 'Surface Stores' etc.\n3. platform: The 'platform' column identifies the means by which a company's products or services are sold. \"Brick \u0026 Mortar\" represents the physical store/location, and \"E-Commerce\" represents online platforms.\n4. channel: The 'channel' column reflects the distribution methods used to sell a product. These methods include \"Retailers\", \"Direct\", and \"Distributors\". Retailers refer to physical or online stores that sell products to consumers. Direct sales refer to sales made directly to consumers through a company's website or other direct means, and distributors refer to intermediaries or middlemen between the manufacturer and retailer or end consumers.\n5. market: The 'market' column lists the countries in which the customer is located.\n6. region: The 'region' column categorizes countries according to their geographic location, including \"APAC\" (Asia Pacific), \"EU\" (Europe), \"NA\" (North America), and \"LATAM\" (Latin America).\n7. sub_zone: \"The 'sub_zone' column further breaks down the regions into sub-regions, such as \"India\", \"ROA\" (Rest of Asia), \"ANZ\" (Australia and New Zealand), \"SE\" Southeast Asia), \"NE\" (Northeast Asia), \"NA\" (North America), and \"LATAM\" (Latin America).\"\n\nColumn Description for dim_product table:\n1. product_code: The 'product_code' column features unique identification codes for each product, serving as a means to track and distinguish individual products within a database or system.\n2. division: The 'division' column categorizes products into groups such as \"P \u0026 A\" (Peripherals and Accessories), \"N \u0026 S\" (Network and Storage) and \"PC\" (Personal Computer).\n3. segment: The 'segment' column categorizes products further within the division, such as \"Peripherals\" (keyboard, mouse, monitor, etc.), \"Accessories\" (cases, cooling solutions, power supplies), \"Notebook\" (laptops), \"Desktop\" (desktops, all-in-one PCs, etc), \"Storage\" (hard disks, SSDs, external storage), and \"Networking\" (routers, switches, modems, etc.).\n4. category: The 'category' column classifies products into specific subcategories within the segment.\n5. product: The 'product' column lists the names of individual products, corresponding to the unique identification codes found in the 'product_code' column.\n6. variant: The \"variant\" column classifies products according to their features, prices, and other characteristics. The column includes variants such as \"Standard\", \"Plus\", \"Premium\" that represent different versions of the same product.\n\nColumn Description for fact_gross_price table:\n1. product_code: The 'product_code' column features unique identification codes for each product.\n2. fiscal_year: The 'fiscal_year' column contains the fiscal period in which the product sale was recorded. A fiscal year is a 12-month period that is used for accounting purposes and often differs from the calendar year. For Atliq Hardware, the fiscal year starts in September. The data available in this column covers the fiscal years 2020 and 2021.\n3. gross_price: The 'gross_price' column holds the initial price of a product, prior to any reductions or taxes. It is the original selling price of the product.\n\nColumn Description for fact_manufacturing_cost:\n1. product_code: The 'product_code' column features unique identification codes for each product\n2. cost_year: The \"cost_year\" column contains the fiscal year in which the product was manufactured.\n3. manufacturing_cost: The \"manufacturing_cost\" column contains the total cost incurred for the production of a product. This cost includes direct costs like raw materials, labor, and overhead expenses that are directly associated with the production process.\n\nColumn Description for fact_pre_invoice_deductions:\n1. customer_code: The 'customer_code' column features unique identification codes for every customer in the dataset. These codes can be used to track a customer's sales history, demographic information, and other relevant details. For example, the codes could look like '70002017', '90005160', and '80007195' respectively.\n2. fiscal_year: The \"fiscal_year\" column holds the fiscal period when the sale of a product occurred.\n3. pre_invoice_discount_pct: The \"pre_invoice_discount_pct\" column contains the percentage of pre-invoice deductions for each product. Pre-invoice deductions are discounts that are applied to the gross price of a product before the invoice is generated, and typically applied to large orders or long-term contracts.\n\nColumn Description for fact_sales_monthly:\n1. date: The \"date\" column contains the date when the sale of a product was made, in a monthly format for 2020 and 2021 fiscal years. This information can be used to understand the sales performance of products over time.\n2. product_code: The \"product_code\" column contains a unique identification code for each product. This code is used to track and differentiate individual products within a database or system.\n3. customer_code: The 'customer_code' column features unique identification codes for every customer in the dataset. These codes can be used to track a customer's sales history, demographic information, and other relevant details. For example, the codes could look like '70002017', '90005160', and '80007195' respectively.\n4. sold_quantity: The \"sold_quantity\" column contains the number of units of a product that were sold. This information can be used to understand the sales volume ofproducts and to compare the sales volume of different products or variants.\n5. fiscal_year: The \"fiscal_year\" column holds the fiscal period when the sale of a product occurred.\n\n\n### Data Cleaning \u0026 Transformation:\n- In PowerBI, Replace Newzealand with New Zealand.\n- Performing data validation of all the datasets.\n\n## 4. ANALYZE  \nData Analyzing  \nMySQL was used to analyze data.  \n\n-- KPI’s REQUIREMENT --  \n#Q1  \nSELECT DISTINCT market  \nFROM dim_customer  \nWHERE customer=\"Atliq Exclusive\" AND region=\"APAC\";  \n\n#Q2  \nWITH cte AS(  \nSELECT COUNT(DISTINCT(product_code)) AS unique_products_2020  \nFROM fact_sales_monthly  \nWHERE fiscal_year=2020),   \ncte1 AS (SELECT COUNT(DISTINCT(product_code)) AS unique_products_2021  \nFROM fact_sales_monthly  \nWHERE fiscal_year=2021)  \nSELECT *, ROUND((unique_products_2021-unique_products_2020)/unique_products_2020 *100, 2) AS percentage_chg  \nFROM cte, cte1;  \n\n#Q3  \nSELECT segment, COUNT(product_code) AS product_count  \nFROM dim_product  \nGROUP BY segment  \nORDER BY product_count DESC;  \n\n#Q4  \nWITH cte1 AS(  \nSELECT d.segment, COUNT(DISTINCT f.product_code) AS product_count_2020  \nFROM dim_product d  \nJOIN fact_sales_monthly f  \nON d.product_code=f.product_code  \nWHERE fiscal_year=2020  \nGROUP BY d.segment),   \ncte2 AS(  \nSELECT d.segment AS segment_, COUNT(DISTINCT f.product_code) AS product_count_2021  \nFROM dim_product d  \nJOIN fact_sales_monthly f  \nON d.product_code=f.product_code  \nWHERE fiscal_year=2021  \nGROUP BY d.segment),   \ncte3 AS(SELECT *, (product_count_2021-product_count_2020) AS difference  \nFROM cte1 c1  \nJOIN cte2 c2  \nON c1.segment=c2.segment_  \nORDER BY difference DESC)  \nSELECT segment, product_count_2020, product_count_2021, difference  \nFROM cte3;  \n\n#Q5  \nSELECT d.product_code, d.product, f.manufacturing_cost   \nFROM dim_product d  \nJOIN fact_manufacturing_cost f  \nON d.product_code=f.product_code  \nWHERE manufacturing_cost= (SELECT MAX(manufacturing_cost) AS max_ FROM fact_manufacturing_cost) OR   \nmanufacturing_cost= (SELECT MIN(manufacturing_cost) AS min_ FROM fact_manufacturing_cost)  \nORDER BY manufacturing_cost DESC;  \n\n#Q6  \nSELECT d.customer_code, d.customer , ROUND(AVG(pre_invoice_discount_pct),4) AS average_discount_percentage  \nFROM dim_customer d  \nJOIN fact_pre_invoice_deductions f  \nON d.customer_code=f.customer_code  \nWHERE f.fiscal_year=2021 AND d.market=\"India\"  \nGROUP BY d.customer_code  \nORDER BY average_discount_percentage DESC  \nLIMIT 5;  \n\t\n#Q7        \nSELECT MONTHNAME(date) AS month_, s.fiscal_year, ROUND(SUM((gross_price*sold_quantity)),2) AS gross_sales_amount        \nFROM fact_gross_price f        \nJOIN fact_sales_monthly s        \nON f.product_code=s.product_code        \t\nJOIN dim_customer d        \nON d.customer_code=s.customer_code        \nWHERE customer=\"Atliq Exclusive\"        \nGROUP BY s.fiscal_year, month_        \nORDER BY s.date;        \n\n#Q8        \nWITH cte AS(        \nSELECT MONTH(date) AS m_, SUM(sold_quantity) AS tot        \nFROM fact_sales_monthly        \nWHERE fiscal_year=2020        \nGROUP BY m_)        \nSELECT CASE WHEN m_ IN(9,10,11) THEN \"1\"        \n\t\t\tWHEN m_ IN(12,1,2) THEN \"2\"        \n\t\t\tWHEN m_ IN (3,4,5) THEN \"3\" ELSE \"4\" END AS Quarters, SUM(tot) AS total_sold_quantity        \nFROM cte        \nGROUP BY Quarters        \nORDER BY total_sold_quantity DESC;        \n\n#9        \nWITH cte AS(        \nSELECT d.channel, ROUND(SUM((f.sold_quantity*g.gross_price))/1000000, 2) AS gross_sales_mln        \nFROM dim_customer d        \nJOIN fact_sales_monthly f        \nON d.customer_code=f.customer_code        \nJOIN fact_gross_price g        \nON f.product_code=g.product_code        \nWHERE f.fiscal_year=2021        \nGROUP BY d.channel        \nORDER BY gross_sales_mln DESC)        \nSELECT *, ROUND(gross_sales_mln/(SELECT SUM(gross_sales_mln) FROM cte)*100, 2) AS percentage        \nFROM cte;        \n\n#10        \nWITH cte AS(        \nSELECT d.division, f.product_code, d.product, SUM(f.sold_quantity) AS total_sold_quantity, RANK() OVER (PARTITION BY d.division ORDER BY SUM(f.sold_quantity) DESC) AS rank_order        \nFROM dim_product d        \nJOIN fact_sales_monthly f        \nON d.product_code = f.product_code        \nWHERE f.fiscal_year = 2021        \nGROUP BY d.division, f.product_code, d.product)        \nSELECT division, product_code, product, total_sold_quantity, rank_order        \nFROM cte        \nWHERE rank_order IN (1, 2, 3);        \n\n\n## 5. SHARE\t\n![Screenshot (105)](https://github.com/iankitnegi/SQL_AdHoc_Analysis_Project/assets/132642567/0d2cf631-79c4-4f59-8270-c869f39f7720)\n![Screenshot (106)](https://github.com/iankitnegi/SQL_AdHoc_Analysis_Project/assets/132642567/c08b0324-fab1-493d-bcad-a57406b74cb5)\n\n\n\n## 6. ACT\n### Insights:\n- AtliQ Exclusive operates its business in eight countries within the APAC region are as follows: India, Indonesia, Japan, Philiphines, South Korea, Australia, New Zealand, Bangladesh.\n- In the fiscal year 2020, we had a total of 245 products, which increased to 334 in the fiscal year 2021, marking a 36% growth.\n- Notebooks, Accessories, and Peripherals are the three top segments.\n- The Accessories segment had the most unique products in 2021 compared to 2020.\n- The AQ HOME Allin1 Gen 2 has the highest manufacturing cost, while the AQ Master wired x1 MS has the lowest manufacturing cost.\n- Flipkart, Viveks, Ezone, Croma, and Amazon offered the highest average discount percentages in the Indian market for the fiscal year 2021.\n- In 2019, September was the lowest performing month, while November saw the highest performance. For 2020, March was the lowest performing month, with November again being the highest.\n- The first quarter of 2020 (September, October, November) saw the highest number of products sold.\n- The retailer channel significantly boosted gross sales in the fiscal year 2021, contributing 73.23%.\n- The top-selling products in the fiscal year 2021 were as follows: N\u0026S Division: AQ Pen Drive 2 in 1, AQ Pen Drive DRC, P\u0026A Division: AQ Gamers MS, AQ Maxima MS, PC Division: AQ Digit, AQ Velocity\n\n\n### Recommendations:\n- Maximize Online Discounts: Work with Flipkart, Viveks, Ezone, Croma, and Amazon for exclusive online deals.\n- Boost March and September: Implement special offers to improve sales during these low months.\n- Cost Reduction: Reduce manufacturing costs for the AQ HOME Allin1 Gen 2.\n- Replicate Q1 Success: Analyze and replicate strategies that boosted first-quarter sales in 2020.\n\nThank you for reading and evaluating my repo :)        \n[LinkedIn](https://www.linkedin.com/posts/iankitnegi_consumer-goods-activity-7208884039053713410-SAWU?utm_source=share\u0026utm_medium=member_desktop)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiankitnegi%2Fsql_adhoc_analysis_project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiankitnegi%2Fsql_adhoc_analysis_project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiankitnegi%2Fsql_adhoc_analysis_project/lists"}