<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Akhil Sharma on Medium]]></title>
        <description><![CDATA[Stories by Akhil Sharma on Medium]]></description>
        <link>https://medium.com/@sakhil1991?source=rss-62c052f29643------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*KUMJhqzgHwYv1GNH</url>
            <title>Stories by Akhil Sharma on Medium</title>
            <link>https://medium.com/@sakhil1991?source=rss-62c052f29643------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 06:29:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sakhil1991/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[ Chocolate Sales Data Analysis Using Advanced SQL (CTEs & Window Functions)]]></title>
            <link>https://medium.com/@sakhil1991/chocolate-sales-data-analysis-using-advanced-sql-ctes-window-functions-6d08d2af6c98?source=rss-62c052f29643------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d08d2af6c98</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[business-analysis]]></category>
            <category><![CDATA[sales-analysis]]></category>
            <dc:creator><![CDATA[Akhil Sharma]]></dc:creator>
            <pubDate>Mon, 02 Feb 2026 01:05:53 GMT</pubDate>
            <atom:updated>2026-02-02T01:05:53.246Z</atom:updated>
            <content:encoded><![CDATA[<p>In this project, I analyzed a <strong>global chocolate sales dataset</strong> using <strong>SQL</strong> to uncover insights related to sales performance, product contribution, country-wise trends, and salesperson efficiency.</p><p>Rather than focusing on basic aggregation, this analysis emphasizes <strong>real-world business questions</strong>, solved using <strong>CTEs, window functions, ranking logic, and percentage contribution analysis</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ShVjAw_IXVocGAPEl8kJHg.png" /></figure><h3>📂 Dataset Overview</h3><p>The dataset contains transactional chocolate sales data with the following columns:</p><ul><li><strong>Sales_Person</strong></li><li><strong>Country</strong></li><li><strong>Product</strong></li><li><strong>Date</strong></li><li><strong>Amount</strong></li><li><strong>Boxes_Shipped</strong></li></ul><p>The data spans multiple countries such as <strong>India, USA, UK, Australia, Canada, and New Zealand</strong>, covering a wide variety of chocolate products.</p><h3>🎯 Business Questions Answered</h3><p>This analysis answers questions like:</p><ul><li>Who are the <strong>top-performing salespersons</strong>?</li><li>Which <strong>products and countries</strong> drive revenue?</li><li>Who contributes <strong>negligible sales</strong>?</li><li>How does revenue change <strong>month-over-month</strong>?</li><li>What is the <strong>percentage contribution</strong> of each product?</li></ul><h3>👤 1. Salespersons with Total Sales Above ₹3,00,000</h3><p><strong>Business Use Case:</strong><br> Identify consistently high-performing salespersons for rewards, promotions, or best-practice sharing.</p><pre>WITH SALES AS (<br>    SELECT Sales_Person,<br>           SUM(Amount) AS TOTAL_SALES<br>    FROM tb1<br>    GROUP BY Sales_Person<br>)<br>SELECT *<br>FROM SALES<br>WHERE TOTAL_SALES &gt; 300000<br>ORDER BY TOTAL_SALES;</pre><p>🔍 <strong>Insight:</strong><br> Only a limited number of salespersons cross this threshold, indicating <strong>performance concentration</strong> within the sales team.</p><h3>🍫 2. Top-Selling Product by Total Revenue</h3><p><strong>Business Use Case:</strong><br> Helps prioritize inventory, marketing spend, and production planning.</p><pre>WITH SALES AS (<br>    SELECT Product,<br>           SUM(Amount) AS TOTAL_SALES<br>    FROM tb1<br>    GROUP BY Product<br>)<br>SELECT *<br>FROM SALES<br>WHERE TOTAL_SALES = (SELECT MAX(TOTAL_SALES) FROM SALES);</pre><p>🔍 <strong>Insight:</strong><br> The top product contributes disproportionately to revenue, making it a <strong>key revenue driver</strong>.</p><h3>🌍 3. Countries with Below-Average Total Sales</h3><p><strong>Business Use Case:</strong><br> Identify underperforming markets that may require pricing changes or promotional strategies.</p><pre>WITH COUNTRY_TOTAL_SALES AS (<br>    SELECT Country,<br>           SUM(Amount) AS TOTAL_SALES<br>    FROM tb1<br>    GROUP BY Country<br>),<br>AVG_SALES AS (<br>    SELECT AVG(TOTAL_SALES) AS AVGL_SALES<br>    FROM COUNTRY_TOTAL_SALES<br>)<br>SELECT *<br>FROM COUNTRY_TOTAL_SALES T, AVG_SALES A<br>WHERE T.TOTAL_SALES &lt; A.AVGL_SALES;</pre><p>🔍 <strong>Insight:</strong><br> Several countries fall below the global average, indicating <strong>regional demand imbalance</strong>.</p><h3>🏆 4. Ranking Salespersons by Total Sales</h3><p><strong>Business Use Case:</strong><br> Create performance leaderboards using ranking logic.</p><pre>SELECT Sales_Person,<br>       SUM(Amount) AS TOTAL_SALES,<br>       DENSE_RANK() OVER (ORDER BY SUM(Amount) DESC) AS Rank_No<br>FROM tb1<br>GROUP BY Sales_Person;</pre><p>🔍 <strong>Insight:</strong><br> Dense ranking helps handle ties fairly and provides a <strong>clear hierarchy of performance</strong>.</p><h3>🌎 5. Top Product per Country</h3><p><strong>Business Use Case:</strong><br> Understand regional product preferences.</p><pre>WITH T1 AS (<br>    SELECT Country, Product,<br>           SUM(Amount) AS TOTAL_SALES,<br>           DENSE_RANK() OVER (PARTITION BY Country ORDER BY SUM(Amount) DESC) AS RANK_NO<br>    FROM tb1<br>    GROUP BY Country, Product<br>)<br>SELECT *<br>FROM T1<br>WHERE RANK_NO = 1;</pre><p>🔍 <strong>Insight:</strong><br> Different countries favor different products — <strong>global strategy must be localized</strong>.</p><h3>⚠️ 6. Salespersons Contributing Less Than 1% of Country Sales</h3><p><strong>Business Use Case:</strong><br> Identify low contributors for training, reassignment, or performance review.</p><pre>WITH COUNTRY_SALE AS (<br>    SELECT Country, SUM(Amount) AS COUNTRY_TOTAL<br>    FROM tb1<br>    GROUP BY Country<br>),<br>PERSONAL_SALE AS (<br>    SELECT Country, Sales_Person,<br>           SUM(Amount) AS PERSON_SALE<br>    FROM tb1<br>    GROUP BY Country, Sales_Person<br>)<br>SELECT *<br>FROM COUNTRY_SALE C<br>JOIN PERSONAL_SALE P<br>ON C.Country = P.Country<br>WHERE P.PERSON_SALE &lt; 0.01 * C.COUNTRY_TOTAL;</pre><p>🔍 <strong>Insight:</strong><br> A long tail of salespersons contributes <strong>very little revenue</strong>, affecting efficiency.</p><h3>📊 7. Product-wise Percentage Contribution to Total Sales</h3><p><strong>Business Use Case:</strong><br> Helps management focus on <strong>high-impact products</strong>.</p><pre>WITH PRODUCT_SALE AS (<br>    SELECT Product,<br>           SUM(Amount) AS PRODUCT_SALE_TOTAL<br>    FROM tb1<br>    GROUP BY Product<br>),<br>TOTAL_SALE AS (<br>    SELECT SUM(PRODUCT_SALE_TOTAL) AS TOTAL<br>    FROM PRODUCT_SALE<br>)<br>SELECT P.Product,<br>       P.PRODUCT_SALE_TOTAL,<br>       CAST(P.PRODUCT_SALE_TOTAL * 100.0 / T.TOTAL AS DECIMAL(10,2)) AS PERCENTAGE_CONTRI<br>FROM PRODUCT_SALE P<br>CROSS JOIN TOTAL_SALE T;</pre><p>🔍 <strong>Insight:</strong><br> A few products contribute a <strong>majority of revenue</strong>, following the <strong>Pareto principle</strong>.</p><h3>📈 8. Month-on-Month Sales Growth Percentage</h3><p><strong>Business Use Case:</strong><br> Track growth trends and detect seasonality.</p><pre>WITH T1 AS (<br>    SELECT MONTH(Date) AS MONTH,<br>           SUM(Amount) AS CURRENT_MONTH_SALES,<br>           LAG(SUM(Amount)) OVER (ORDER BY MONTH(Date)) AS PREV_MONTH_SALES<br>    FROM tb1<br>    GROUP BY MONTH(Date)<br>)<br>SELECT MONTH,<br>       CURRENT_MONTH_SALES,<br>       PREV_MONTH_SALES,<br>       (CURRENT_MONTH_SALES - PREV_MONTH_SALES) * 100 / PREV_MONTH_SALES AS MOM_GAIN<br>FROM T1<br>WHERE PREV_MONTH_SALES IS NOT NULL;</pre><p>🔍 <strong>Insight:</strong><br> Sales fluctuate month-to-month, highlighting <strong>seasonal demand patterns</strong>.</p><h3>🧠 Key Learnings</h3><p>✔ CTEs improve <strong>query readability and logic separation</strong><br> ✔ Window functions enable <strong>ranking, trend, and comparison analysis</strong><br> ✔ SQL can answer <strong>complex business questions without BI tools</strong><br> ✔ Sales performance is driven more by <strong>product mix than volume</strong></p><h3>🚀 Conclusion</h3><p>This project demonstrates how <strong>SQL is not just a querying language — but a decision-making tool</strong>.<br> By applying analytical thinking with CTEs and window functions, raw sales data was transformed into <strong>clear, actionable business insights</strong>.</p><p>This type of analysis closely mirrors <strong>real-world Business Analyst and Data Analyst responsibilities</strong>, especially in retail and FMCG domains.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d08d2af6c98" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Mastering CTEs, Recursive CTEs, and Views in SQL]]></title>
            <link>https://medium.com/@sakhil1991/mastering-ctes-recursive-ctes-and-views-in-sql-56f1fa7d9694?source=rss-62c052f29643------2</link>
            <guid isPermaLink="false">https://medium.com/p/56f1fa7d9694</guid>
            <category><![CDATA[views]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[business-analytics]]></category>
            <category><![CDATA[cte]]></category>
            <dc:creator><![CDATA[Akhil Sharma]]></dc:creator>
            <pubDate>Sun, 25 Jan 2026 02:09:34 GMT</pubDate>
            <atom:updated>2026-01-25T02:09:34.428Z</atom:updated>
            <content:encoded><![CDATA[<h3>🧩 Clean, Scalable Queries for Real-World Use</h3><p>As SQL queries become more complex — especially with <strong>aggregation, joins, or hierarchical data</strong> — subqueries can make your code hard to read, difficult to maintain, and inefficient.</p><p>This is where <strong>CTEs</strong>, <strong>Recursive CTEs</strong>, and <strong>Views</strong> shine. They are <strong>not just SQL features</strong> but <strong>design tools</strong> that make your queries <strong>clean, readable, and reusable</strong>.</p><p>In this article, we cover:</p><ul><li>✅ Definitions of CTEs and Views</li><li>✅ Properties and types</li><li>✅ Advantages over subqueries</li><li>✅ Practical query examples</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZVkEUrMetEFgUwuN9nfvvg.png" /></figure><h3>🔹 What Is a Common Table Expression (CTE)?</h3><p>A <strong>CTE</strong> is a <strong>temporary named result set</strong> defined using the WITH keyword.<br> It exists <strong>only for the duration of a single query</strong> and helps <strong>break complex SQL into readable steps</strong>.</p><h3>📌 Properties of CTE</h3><ul><li>⏱ <strong>Temporary Scope:</strong> Exists only during query execution</li><li>📖 <strong>Readable &amp; Modular:</strong> Makes SQL easier to understand</li><li>🔄 <strong>Reusable Within Query:</strong> Can reference multiple times in the same query</li><li>➕ <strong>Supports Aggregation:</strong> Works with SUM, AVG, COUNT, MAX, MIN</li><li>🔗 <strong>Supports Joins:</strong> Can be joined with tables or other CTEs</li><li>🔁 <strong>Supports Recursion:</strong> Can reference itself for hierarchical data</li><li>❌ <strong>Not Stored in Database:</strong> Disappears after query execution</li></ul><h3>🔹 Types of CTE</h3><h4>1️⃣ Non-Recursive (Simple) CTE</h4><p>A <strong>Non-Recursive CTE</strong> is used to simplify complex queries and is referenced only once.</p><pre>WITH DeptAvgSalary AS (<br>    SELECT department_id, AVG(salary) AS avg_salary<br>    FROM employee<br>    GROUP BY department_id<br>)<br>SELECT * FROM DeptAvgSalary;</pre><h4>2️⃣ Recursive CTE</h4><p>A <strong>Recursive CTE</strong> is a CTE that <strong>references itself</strong>, which allows it to handle <strong>hierarchical or iterative data</strong>.</p><p>It has <strong>two main parts</strong>:</p><ol><li><strong>Anchor member</strong> — The starting point of recursion</li><li><strong>Recursive member</strong> — References the CTE itself and defines how it should iterate</li></ol><h3>🔹 Recursive CTE Examples</h3><h4>👥 Employee–Manager Hierarchy</h4><pre>WITH RECURSIVE EmpHierarchy AS (<br>    SELECT emp_id, emp_name, manager_id, 1 AS level<br>    FROM employee<br>    WHERE manager_id IS NULL<br>UNION ALL<br>    SELECT e.emp_id, e.emp_name, e.manager_id, h.level + 1<br>    FROM employee e<br>    JOIN EmpHierarchy h<br>    ON e.manager_id = h.emp_id<br>)<br>SELECT * FROM EmpHierarchy;</pre><h4>🔢 Counting Numbers (1 to 10)</h4><pre>WITH RECURSIVE Numbers AS (<br>    -- Anchor query: start from 1<br>    SELECT 1 AS num<br>UNION ALL<br>    -- Recursive query: increment by 1 until 10<br>    SELECT num + 1<br>    FROM Numbers<br>    WHERE num &lt; 10<br>)<br>SELECT * FROM Numbers;</pre><h3>🔹 CTE with Aggregation and Joins</h3><h4>💰 Employees Earning More Than Department Average</h4><pre>WITH DeptAvgSalary AS (<br>    SELECT department_id, AVG(salary) AS avg_salary<br>    FROM employee<br>    GROUP BY department_id<br>)<br>SELECT e.emp_id, e.emp_name, e.department_id, e.salary<br>FROM employee e<br>JOIN DeptAvgSalary d<br>ON e.department_id = d.department_id<br>WHERE e.salary &gt; d.avg_salary;</pre><h4>🏢 Department Salary and Employee Count</h4><pre>WITH DeptAvg AS (<br>    SELECT department_id, AVG(salary) AS avg_salary<br>    FROM employee<br>    GROUP BY department_id<br>),<br>DeptCount AS (<br>    SELECT department_id, COUNT(*) AS emp_count<br>    FROM employee<br>    GROUP BY department_id<br>)<br>SELECT a.department_id, a.avg_salary, c.emp_count<br>FROM DeptAvg a<br>JOIN DeptCount c<br>ON a.department_id = c.department_id;</pre><h3>🔹 What Is a View in SQL?</h3><p>A <strong>View</strong> is a <strong>virtual table</strong> created by storing a SQL query in the database.<br> Unlike CTEs, <strong>Views are permanent</strong> and can be reused in multiple queries or applications.</p><h3>📌 Properties of Views</h3><ul><li>🏛 <strong>Permanent Object:</strong> Stored in the database</li><li>🔄 <strong>Reusable:</strong> Can be referenced multiple times</li><li>📜 <strong>Virtual Table:</strong> Does not store data itself</li><li>🧩 <strong>Simplifies Queries:</strong> Hides complex joins and aggregations</li><li>🔒 <strong>Improves Security:</strong> Restrict column or row access</li><li>➕ <strong>Supports Aggregation &amp; Joins:</strong> Can include GROUP BY and joins</li><li>🛠 <strong>Centralizes Business Logic:</strong> Ensures consistent results</li></ul><h3>🔹 Examples of Views</h3><h4>👤 Simple View</h4><pre>CREATE VIEW ActiveEmployees AS<br>SELECT emp_id, emp_name<br>FROM employee<br>WHERE status = &#39;ACTIVE&#39;;</pre><h4>📊 View with Aggregation</h4><pre>CREATE VIEW DeptSalarySummary AS<br>SELECT department_id, AVG(salary) AS avg_salary, SUM(salary) AS total_salary<br>FROM employee<br>GROUP BY department_id;</pre><h4>🔗 View with Join</h4><pre>CREATE VIEW EmployeeDepartment AS<br>SELECT e.emp_id, e.emp_name, d.department_name<br>FROM employee e<br>JOIN department d<br>ON e.department_id = d.department_id;</pre><h3>🔹 Advantages of CTEs and Views Over Subqueries</h3><ul><li>✨ <strong>Improved Readability:</strong> Break queries into logical steps</li><li>🐞 <strong>Easier Debugging:</strong> Isolate calculation logic</li><li>🔄 <strong>Reusable Logic:</strong> Views can be reused across queries</li><li>🛠 <strong>Better Maintenance:</strong> Centralized aggregation, joins, filters</li><li>🌳 <strong>Supports Hierarchical Data:</strong> Recursive CTEs handle trees</li></ul><h3>🔹 When to Use</h3><ul><li><strong>CTEs:</strong> Complex, one-time queries</li><li><strong>Recursive CTEs:</strong> Hierarchical or iterative data</li><li><strong>Views:</strong> Reusable business logic, reporting, dashboards</li><li><strong>Subqueries:</strong> Only for simple inline filtering</li></ul><h3>🔹 Final Thoughts</h3><p>CTEs, Recursive CTEs, and Views transform SQL from a query language into a <strong>professional design tool</strong>.</p><blockquote>Clean SQL doesn’t just return results — it tells a story. Master CTEs and Views to write readable, reusable, and scalable SQL.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56f1fa7d9694" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ KBC Game in Python — A Beginner Project Using Lists and Functions]]></title>
            <link>https://medium.com/@sakhil1991/kbc-game-in-python-a-beginner-project-using-lists-and-functions-105887e071bc?source=rss-62c052f29643------2</link>
            <guid isPermaLink="false">https://medium.com/p/105887e071bc</guid>
            <category><![CDATA[business-analysis]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Akhil Sharma]]></dc:creator>
            <pubDate>Sat, 24 Jan 2026 10:08:18 GMT</pubDate>
            <atom:updated>2026-01-24T10:08:18.119Z</atom:updated>
            <content:encoded><![CDATA[<h3>🏆 KBC Game in Python — A Beginner Project Using Lists and Functions</h3><h3>📌 Introduction</h3><p><strong>Kaun Banega Crorepati (KBC)</strong> is one of India’s most iconic quiz shows.<br> In this project, I built a <strong>console-based KBC game in Python</strong> using only <strong>basic programming concepts</strong>.</p><p>The goal of this project is to show that <strong>even simple Python features like lists and functions</strong> are enough to build a complete, interactive application.</p><p>This project is ideal for:</p><ul><li>Python beginners</li><li>Students</li><li>Interview practice</li><li>Logic-building exercises</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G2Cqv-2OGjMpDdx5hzVXmw.png" /></figure><h3>🎯 Project Objective</h3><p>The objective of this project is to simulate a real KBC game experience in the terminal:</p><ul><li>15 quiz questions</li><li>Increasing prize money</li><li>3 lifelines</li><li>Safe haven levels</li><li>Quit option</li><li>Final prize of ₹7 Crore</li></ul><p>All of this is implemented using <strong>simple lists and functions</strong>, without any advanced concepts.</p><h3>🗂️ Data Storage — Using a Simple List</h3><p>All questions are stored inside a <strong>single Python list</strong>.</p><p>Each question is represented as a sub-list containing:</p><ul><li>Question text</li><li>Four options (A, B, C, D)</li><li>Correct answer</li><li>Prize money</li></ul><h3>✔ Why lists are used:</h3><ul><li>Easy to understand</li><li>Easy to access using index</li><li>Easy to loop through</li><li>No database required</li><li>Perfect for beginners</li></ul><p>This makes the project <strong>simple, readable, and maintainable</strong>.</p><h3>🧩 Project Structure — Function-Based Design</h3><p>The entire game is divided into <strong>small functions</strong>, where each function handles one responsibility.</p><p>This approach follows <strong>modular programming</strong>, which is a good coding practice.</p><h3>🔹 Welcome Screen Function</h3><p><strong>Purpose:</strong></p><ul><li>Displays game title</li><li>Shows rules</li><li>Shows available lifelines</li><li>Starts the game</li></ul><p>This improves the <strong>user experience</strong> and keeps the main logic clean.</p><h3>🔹 Question Display Function</h3><p><strong>Purpose:</strong></p><ul><li>Displays question number</li><li>Shows prize money</li><li>Prints question and options</li></ul><p>Separating this logic makes the code easier to read and reuse.</p><h3>🔹 Lifeline Display Function</h3><p><strong>Purpose:</strong></p><ul><li>Shows available lifelines</li><li>Indicates used lifelines</li><li>Helps the player make decisions</li></ul><p>This function improves clarity during gameplay.</p><h3>🔹 50–50 Lifeline Function</h3><p><strong>Logic:</strong></p><ul><li>Keeps the correct answer</li><li>Randomly removes two incorrect options</li><li>Displays only remaining choices</li></ul><p>This lifeline uses Python’s random module to simulate real KBC behavior.</p><h3>🔹 Audience Poll Lifeline</h3><p><strong>Logic:</strong></p><ul><li>Displays audience voting percentages</li><li>Gives the highest percentage to the correct answer</li></ul><p>This creates a <strong>realistic quiz-show experience</strong> using simple conditional logic.</p><h3>🔹 Answer Validation Function</h3><p><strong>Purpose:</strong></p><ul><li>Checks if the user’s answer is correct</li><li>Displays result</li><li>Updates prize money</li><li>Controls game flow</li></ul><p>This function acts as the <strong>decision-making core</strong> of the game.</p><h3>🔹 Main Game Controller Function</h3><p>This is the <strong>heart of the project</strong>.</p><p>It manages:</p><ul><li>Game flow</li><li>Question loop</li><li>Lifeline usage</li><li>User input</li><li>Safe haven levels</li><li>Win condition</li><li>Quit option</li><li>Replay logic</li></ul><p>All other functions are connected here.</p><h3>⭐ Key Features of the Project</h3><ul><li>Console-based interactive game</li><li>List-based question management</li><li>Function-oriented design</li><li>Real KBC-style flow</li><li>Three lifelines</li><li>Safe haven system</li><li>Quit and replay options</li><li>Beginner-friendly logic</li></ul><h3>🛠️ Python Concepts Used</h3><ul><li>list – store questions</li><li>function – modular programming</li><li>for loop – iterate through questions</li><li>while loop – input validation</li><li>if-else – decision making</li><li>random – lifeline logic</li><li>time.sleep() – realistic delay</li><li>input() – user interaction</li></ul><h3>📚 Learning Outcomes</h3><p>By completing this project, you learn:</p><ul><li>How to structure a Python project</li><li>How to use functions effectively</li><li>How to manage game logic</li><li>How lists can act as simple databases</li><li>How to write clean, readable code</li><li>How modular programming works</li></ul><h3>🚀 Why This Project Is Beginner-Friendly</h3><p>This project <strong>does NOT use</strong>:</p><ul><li>Classes or OOP</li><li>Databases</li><li>APIs</li><li>GUI frameworks</li><li>External libraries</li></ul><p>It uses only:</p><ul><li>Lists</li><li>Functions</li><li>Loops</li><li>Conditions</li></ul><p>That makes it <strong>perfect for beginners</strong> and easy to explain in interviews.</p><h3>💻 Complete Project Source Code</h3><pre><br>import random<br>import time<br><br># List of all questions with their answers and prize money<br>questions = [<br>    [&quot;Which is the national bird of India?&quot;, &quot;A) Parrot&quot;, &quot;B) Peacock&quot;, &quot;C) Eagle&quot;, &quot;D) Sparrow&quot;, &quot;B&quot;, &quot;₹1,000&quot;],<br>    [&quot;How many states are there in India?&quot;, &quot;A) 28&quot;, &quot;B) 29&quot;, &quot;C) 27&quot;, &quot;D) 30&quot;, &quot;A&quot;, &quot;₹2,000&quot;],<br>    [&quot;What is the capital of India?&quot;, &quot;A) Mumbai&quot;, &quot;B) Kolkata&quot;, &quot;C) New Delhi&quot;, &quot;D) Chennai&quot;, &quot;C&quot;, &quot;₹5,000&quot;],<br>    [&quot;Who wrote the Indian National Anthem?&quot;, &quot;A) Bankim Chandra&quot;, &quot;B) Rabindranath Tagore&quot;, &quot;C) Sarojini Naidu&quot;, &quot;D) Mahatma Gandhi&quot;, &quot;B&quot;, &quot;₹10,000&quot;],<br>    [&quot;How many colors are in a rainbow?&quot;, &quot;A) 5&quot;, &quot;B) 6&quot;, &quot;C) 7&quot;, &quot;D) 8&quot;, &quot;C&quot;, &quot;₹20,000&quot;],<br>    [&quot;Which planet is the Morning Star?&quot;, &quot;A) Mars&quot;, &quot;B) Venus&quot;, &quot;C) Mercury&quot;, &quot;D) Jupiter&quot;, &quot;B&quot;, &quot;₹40,000&quot;],<br>    [&quot;When did India win first Cricket World Cup?&quot;, &quot;A) 1975&quot;, &quot;B) 1979&quot;, &quot;C) 1983&quot;, &quot;D) 1987&quot;, &quot;C&quot;, &quot;₹80,000&quot;],<br>    [&quot;What is the currency of Japan?&quot;, &quot;A) Yuan&quot;, &quot;B) Won&quot;, &quot;C) Ringgit&quot;, &quot;D) Yen&quot;, &quot;D&quot;, &quot;₹1,60,000&quot;],<br>    [&quot;Who is the Iron Man of India?&quot;, &quot;A) Jawaharlal Nehru&quot;, &quot;B) Sardar Patel&quot;, &quot;C) Subhas Bose&quot;, &quot;D) Lal Bahadur Shastri&quot;, &quot;B&quot;, &quot;₹3,20,000&quot;],<br>    [&quot;Which is the longest river in the world?&quot;, &quot;A) Amazon&quot;, &quot;B) Nile&quot;, &quot;C) Yangtze&quot;, &quot;D) Mississippi&quot;, &quot;B&quot;, &quot;₹6,40,000&quot;],<br>    [&quot;What is the smallest bone in human body?&quot;, &quot;A) Stapes&quot;, &quot;B) Femur&quot;, &quot;C) Radius&quot;, &quot;D) Tibia&quot;, &quot;A&quot;, &quot;₹12,50,000&quot;],<br>    [&quot;Chemical symbol &#39;Au&#39; is for which element?&quot;, &quot;A) Silver&quot;, &quot;B) Aluminum&quot;, &quot;C) Gold&quot;, &quot;D) Argon&quot;, &quot;C&quot;, &quot;₹25,00,000&quot;],<br>    [&quot;First woman to win a Nobel Prize?&quot;, &quot;A) Mother Teresa&quot;, &quot;B) Marie Curie&quot;, &quot;C) Rosa Parks&quot;, &quot;D) Malala&quot;, &quot;B&quot;, &quot;₹50,00,000&quot;],<br>    [&quot;Mount Everest is in which mountain range?&quot;, &quot;A) Andes&quot;, &quot;B) Alps&quot;, &quot;C) Himalayas&quot;, &quot;D) Rockies&quot;, &quot;C&quot;, &quot;₹1,00,00,000&quot;],<br>    [&quot;In which year did World War II end?&quot;, &quot;A) 1943&quot;, &quot;B) 1944&quot;, &quot;C) 1945&quot;, &quot;D) 1946&quot;, &quot;C&quot;, &quot;₹7,00,00,000&quot;]<br>]<br><br># Function to show welcome message<br>def show_welcome():<br>    print(&quot;=&quot;*50)<br>    print(&quot;        WELCOME TO KBC!&quot;)<br>    print(&quot;=&quot;*50)<br>    time.sleep(1)<br>    print(&quot;\nAnswer 15 questions to win ₹7 CRORE!&quot;)<br>    time.sleep(0.5)<br>    print(&quot;\nLifelines: 1) 50-50  2) Audience Poll  3) Skip the Question&quot;)<br>    print(&quot;\n&quot; + &quot;=&quot;*50)<br>    input(&quot;\nPress Enter to start...&quot;)<br><br># Function to display a question<br>def show_question(question_number, question_data):<br>    print(&quot;=&quot;*50)<br>    print(f&quot;Question {question_number} for {question_data[6]}&quot;)<br>    print(&quot;=&quot;*50)<br>    time.sleep(0.8)<br>    print(f&quot;\n{question_data[0]}&quot;)<br>    time.sleep(0.5)<br>    print(f&quot;\n  {question_data[1]}&quot;)<br>    print(f&quot;  {question_data[2]}&quot;)<br>    print(f&quot;  {question_data[3]}&quot;)<br>    print(f&quot;  {question_data[4]}&quot;)<br>    time.sleep(0.3)<br><br># Function to show available lifelines<br>def show_lifelines(lifeline_5050, lifeline_poll, lifeline_skip):<br>    print(&quot;\n--- LIFELINES ---&quot;)<br>    <br>    if lifeline_5050:<br>        print(&quot;1) 50-50 ✓&quot;)<br>    else:<br>        print(&quot;1)2 50-50 ✗ (Used)&quot;)<br>    <br>    if lifeline_poll:<br>        print(&quot;2) Audience Poll ✓&quot;)<br>    else:<br>        print(&quot;2) Audience Poll ✗ (Used)&quot;)<br>    <br>    if lifeline_skip:<br>        print(&quot;3) Skip Question ✓&quot;)<br>    else:<br>        print(&quot;3) Skip Question ✗ (Used)&quot;)<br><br># Function for 50-50 lifeline<br>def use_5050(question_data):<br>    print(&quot;\nUsing 50-50...&quot;)<br>    time.sleep(1)<br>    correct_answer = question_data[5]<br>    <br>    # Create list of all options<br>    all_options = [&quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot;]<br>    <br>    # Remove the correct answer from the list<br>    all_options.remove(correct_answer)<br>    <br>    # Remove two random wrong answers<br>    to_remove = random.sample(all_options, 2)<br>    <br>    # Display remaining options<br>    print(&quot;\nRemoving 2 wrong answers...&quot;)<br>    time.sleep(1.5)<br>    print(&quot;\nRemaining options:&quot;)<br>    time.sleep(0.5)<br>    <br>    # Show only options that are NOT removed<br>    if &quot;A&quot; not in to_remove:<br>        print(f&quot;  {question_data[1]}&quot;)<br>    if &quot;B&quot; not in to_remove:<br>        print(f&quot;  {question_data[2]}&quot;)<br>    if &quot;C&quot; not in to_remove:<br>        print(f&quot;  {question_data[3]}&quot;)<br>    if &quot;D&quot; not in to_remove:<br>        print(f&quot;  {question_data[4]}&quot;)<br><br># Function for Audience Poll lifeline<br>def use_audience_poll(question_data):<br>    print(&quot;\nUsing Audience Poll...&quot;)<br>    time.sleep(1)<br>    print(&quot;\nAsking the audience...&quot;)<br>    time.sleep(1.5)<br>    <br>    correct_answer = question_data[5]<br>    <br>    print(&quot;\nAudience Poll Results:&quot;)<br>    time.sleep(0.5)<br>    <br>    # Show poll with correct answer having highest percentage<br>    if correct_answer == &quot;A&quot;:<br>        print(&quot;A: 75%&quot;)<br>        print(&quot;B: 15%&quot;)<br>        print(&quot;C: 7%&quot;)<br>        print(&quot;D: 3%&quot;)<br>    elif correct_answer == &quot;B&quot;:<br>        print(&quot;A: 8%&quot;)<br>        print(&quot;B: 72%&quot;)<br>        print(&quot;C: 12%&quot;)<br>        print(&quot;D: 8%&quot;)<br>    elif correct_answer == &quot;C&quot;:<br>        print(&quot;A: 10%&quot;)<br>        print(&quot;B: 8%&quot;)<br>        print(&quot;C: 78%&quot;)<br>        print(&quot;D: 4%&quot;)<br>    else:<br>        print(&quot;A: 6%&quot;)<br>        print(&quot;B: 11%&quot;)<br>        print(&quot;C: 8%&quot;)<br>        print(&quot;D: 75%&quot;)<br><br># Function to check if answer is correct<br>def check_answer(user_answer, correct_answer, prize_money, question_number):<br>    print(&quot;\nChecking your answer...&quot;)<br>    time.sleep(1)<br>    print(&quot;.&quot; * 20)<br>    time.sleep(2)<br>    <br>    if user_answer == correct_answer:<br>        print(f&quot;\nCORRECT! You won {prize_money}!&quot;)<br>        time.sleep(1)<br>        return True<br>    else:<br>        print(f&quot;\nWRONG! Correct answer was {correct_answer}&quot;)<br>        time.sleep(1)<br>        return False<br><br># Main game function<br>def play_game():<br>    # Show welcome screen<br>    show_welcome()<br>    <br>    # Lifeline variables<br>    lifeline_5050 = True<br>    lifeline_poll = True<br>    lifeline_skip = True<br>    <br>    # Money tracking<br>    money_won = &quot;₹0&quot;<br>    safe_money = &quot;₹0&quot;<br>    <br>    # Main game loop - go through each question<br>    for i in range(len(questions)):<br>        question_number = i + 1<br>        current_question = questions[i]<br>        <br>        # Show the question<br>        show_question(question_number, current_question)<br>        <br>        # Get user&#39;s answer<br>        answer_given = False<br>        <br>        while answer_given == False:<br>            print(&quot;\n- Type A, B, C, or D for your answer&quot;)<br>            print(&quot;- Type L to use lifeline&quot;)<br>            print(&quot;- Type Q to quit and take money home&quot;)<br>            <br>            user_input = input(&quot;\nYour choice: &quot;).upper()<br>            <br>            # If user wants to quit<br>            if user_input == &quot;Q&quot;:<br>                print(f&quot;\nYou are taking home {money_won}&quot;)<br>                print(&quot;Thanks for playing!&quot;)<br>                return<br>            <br>            # If user wants lifeline<br>            elif user_input == &quot;L&quot;:<br>                show_lifelines(lifeline_5050, lifeline_poll, lifeline_skip)<br>                <br>                lifeline_choice = input(&quot;\nWhich lifeline? (1/2/3): &quot;)<br>                <br>                if lifeline_choice == &quot;1&quot; and lifeline_5050:<br>                    use_5050(current_question)<br>                    lifeline_5050 = False<br>                <br>                elif lifeline_choice == &quot;2&quot; and lifeline_poll:<br>                    use_audience_poll(current_question)<br>                    lifeline_poll = False<br>                <br>                elif lifeline_choice == &quot;3&quot; and lifeline_skip:<br>                    print(&quot;\nSkipping the question!&quot;)<br>                    time.sleep(1)<br>                    print(&quot;Moving to next question...&quot;)<br>                    time.sleep(1)<br>                    lifeline_skip = False<br>                    break<br>                <br>                else:<br>                    print(&quot;\nLifeline not available or invalid choice!&quot;)<br>            <br>            # If user gives answer<br>            elif user_input in [&quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot;]:<br>                answer_given = True<br>                correct_answer = current_question[5]<br>                prize_money = current_question[6]<br>                <br>                # Check answer<br>                is_correct = check_answer(user_input, correct_answer, prize_money, question_number)<br>                <br>                if is_correct:<br>                    money_won = prize_money<br>                    <br>                    # Safe haven at question 4 and 9<br>                    if question_number == 4 or question_number == 9:<br>                        safe_money = money_won<br>                        time.sleep(0.5)<br>                        print(f&quot;SAFE HAVEN! Minimum winning: {safe_money}&quot;)<br>                        time.sleep(1.5)<br>                    <br>                    # Check if won the game<br>                    if question_number == 15:<br>                        time.sleep(1)<br>                        print(&quot;\n&quot; + &quot;=&quot;*50)<br>                        print(&quot;YOU WON ₹7 CRORE! CONGRATULATIONS!&quot;)<br>                        print(&quot;=&quot;*50)<br>                        time.sleep(2)<br>                        return<br>                <br>                else:<br>                    print(f&quot;You are taking home {safe_money}&quot;)<br>                    print(&quot;\nGame Over! Better luck next time!&quot;)<br>                    return<br>            <br>            else:<br>                print(&quot;\nInvalid input! Try again.&quot;)<br><br># Start the game<br>while True:<br>    play_game()<br>    <br>    # Ask to play again<br>    print(&quot;\n&quot; + &quot;=&quot;*50)<br>    play_again = input(&quot;Play again? (yes/no): &quot;).lower()<br>    <br>    if play_again == &quot;yes&quot;:<br>        print(&quot;\nStarting new game...\n&quot;)<br>        time.sleep(1)<br>    else:<br>        print(&quot;\nThanks for playing KBC! Goodbye!&quot;)<br>        break</pre><h3>🧾 Code Output</h3><pre>==================================================<br>        WELCOME TO KBC!<br>==================================================<br><br>Answer 15 questions to win ₹7 CRORE!<br><br>Lifelines: 1) 50-50  2) Audience Poll  3) Skip the Question<br><br>==================================================<br><br>Press Enter to start...<br>==================================================<br>Question 1 for ₹1,000<br>==================================================<br><br>Which is the national bird of India?<br><br>  A) Parrot<br>  B) Peacock<br>  C) Eagle<br>  D) Sparrow<br><br>- Type A, B, C, or D for your answer<br>- Type L to use lifeline<br>- Type Q to quit and take money home<br><br>Your choice: b<br><br>Checking your answer...<br>....................<br><br>CORRECT! You won ₹1,000!<br>==================================================<br>Question 2 for ₹2,000<br>==================================================<br><br>How many states are there in India?<br><br>  A) 28<br>  B) 29<br>  C) 27<br>  D) 30<br><br>- Type A, B, C, or D for your answer<br>- Type L to use lifeline<br>- Type Q to quit and take money home<br><br>Your choice: l<br><br>--- LIFELINES ---<br>1) 50-50 ✓<br>2) Audience Poll ✓<br>3) Skip Question ✓<br><br>Which lifeline? (1/2/3): 3<br><br>Skipping the question!<br>Moving to next question...<br>==================================================<br>Question 3 for ₹5,000<br>==================================================<br><br>What is the capital of India?<br><br>  A) Mumbai<br>  B) Kolkata<br>  C) New Delhi<br>  D) Chennai<br><br>- Type A, B, C, or D for your answer<br>- Type L to use lifeline<br>- Type Q to quit and take money home<br><br>Your choice: c<br><br>Checking your answer...<br>....................<br><br>CORRECT! You won ₹5,000!<br>==================================================<br>Question 4 for ₹10,000<br>==================================================<br><br>Who wrote the Indian National Anthem?<br><br>  A) Bankim Chandra<br>  B) Rabindranath Tagore<br>  C) Sarojini Naidu<br>  D) Mahatma Gandhi<br><br>- Type A, B, C, or D for your answer<br>- Type L to use lifeline<br>- Type Q to quit and take money home<br><br>Your choice: q<br><br>You are taking home ₹5,000<br>Thanks for playing!<br><br>==================================================<br>Play again? (yes/no): yes<br><br>Starting new game...<br><br>==================================================<br>        WELCOME TO KBC!<br>==================================================<br><br>Answer 15 questions to win ₹7 CRORE!<br><br>Lifelines: 1) 50-50  2) Audience Poll  3) Skip the Question<br><br>==================================================<br><br>Press Enter to start...<br>==================================================<br>Question 1 for ₹1,000<br>==================================================<br><br>Which is the national bird of India?<br><br>  A) Parrot<br>  B) Peacock<br>  C) Eagle<br>  D) Sparrow<br><br>- Type A, B, C, or D for your answer<br>- Type L to use lifeline<br>- Type Q to quit and take money home<br><br>Your choice: b<br><br>Checking your answer...<br>....................<br><br>CORRECT! You won ₹1,000!<br>==================================================<br>Question 2 for ₹2,000<br>==================================================<br><br>How many states are there in India?<br><br>  A) 28<br>  B) 29<br>  C) 27<br>  D) 30<br><br>- Type A, B, C, or D for your answer<br>- Type L to use lifeline<br>- Type Q to quit and take money home<br><br>Your choice: l<br><br>--- LIFELINES ---<br>1) 50-50 ✓<br>2) Audience Poll ✓<br>3) Skip Question ✓<br><br>Which lifeline? (1/2/3): 1<br><br>Using 50-50...<br><br>Removing 2 wrong answers...<br><br>Remaining options:<br>  A) 28<br>  D) 30<br><br>- Type A, B, C, or D for your answer<br>- Type L to use lifeline<br>- Type Q to quit and take money home<br><br>Your choice: j<br><br>Invalid input! Try again.<br><br>- Type A, B, C, or D for your answer<br>- Type L to use lifeline<br>- Type Q to quit and take money home<br><br>Your choice: a<br><br>Checking your answer...<br>....................<br><br>CORRECT! You won ₹2,000!<br>==================================================<br>Question 3 for ₹5,000<br>==================================================<br><br>What is the capital of India?<br><br>  A) Mumbai<br>  B) Kolkata<br>  C) New Delhi<br>  D) Chennai<br><br>- Type A, B, C, or D for your answer<br>- Type L to use lifeline<br>- Type Q to quit and take money home<br><br>Your choice: d<br><br>Checking your answer...<br>....................<br><br>WRONG! Correct answer was C<br>You are taking home ₹0<br><br>Game Over! Better luck next time!<br><br>==================================================<br>Play again? (yes/no): yes<br><br>Starting new game...<br><br>==================================================<br>        WELCOME TO KBC!<br>==================================================<br><br>Answer 15 questions to win ₹7 CRORE!<br><br>Lifelines: 1) 50-50  2) Audience Poll  3) Skip the Question<br><br>==================================================<br><br>Press Enter to start...<br>==================================================<br>Question 1 for ₹1,000<br>==================================================<br><br>Which is the national bird of India?<br><br>  A) Parrot<br>  B) Peacock<br>  C) Eagle<br>  D) Sparrow<br><br>- Type A, B, C, or D for your answer<br>- Type L to use lifeline<br>- Type Q to quit and take money home<br><br>Your choice: l<br><br>--- LIFELINES ---<br>1) 50-50 ✓<br>2) Audience Poll ✓<br>3) Skip Question ✓<br><br>Which lifeline? (1/2/3): 2<br><br>Using Audience Poll...<br><br>Asking the audience...<br><br>Audience Poll Results:<br>A: 8%<br>B: 72%<br>C: 12%<br>D: 8%<br><br>- Type A, B, C, or D for your answer<br>- Type L to use lifeline<br>- Type Q to quit and take money home<br><br>Your choice: b<br><br>Checking your answer...<br>....................<br><br>CORRECT! You won ₹1,000!<br>==================================================<br>Question 2 for ₹2,000<br>==================================================<br><br>How many states are there in India?<br><br>  A) 28<br>  B) 29<br>  C) 27<br>  D) 30<br><br>- Type A, B, C, or D for your answer<br>- Type L to use lifeline<br>- Type Q to quit and take money home<br><br>Your choice: q<br><br>You are taking home ₹1,000<br>Thanks for playing!<br><br>==================================================<br>Play again? (yes/no):</pre><h3>🏁 Conclusion</h3><p>This KBC game project demonstrates that:</p><ul><li>Real-world applications can be built using basic Python</li><li>Lists and functions are powerful when used correctly</li><li>Clean structure makes programs easy to understand and maintain</li></ul><p>This project is an excellent example of how <strong>simple logic + good structure = strong foundation</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=105887e071bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Customer Bank Accounts Analysis Using SQL (CTEs & Views)]]></title>
            <link>https://medium.com/@sakhil1991/customer-bank-accounts-analysis-using-sql-ctes-views-f2415ff4fe69?source=rss-62c052f29643------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2415ff4fe69</guid>
            <dc:creator><![CDATA[Akhil Sharma]]></dc:creator>
            <pubDate>Fri, 23 Jan 2026 13:23:17 GMT</pubDate>
            <atom:updated>2026-01-23T13:23:17.617Z</atom:updated>
            <content:encoded><![CDATA[<p>In the banking industry, data-driven decisions are critical for understanding customer behavior, managing risk, and improving profitability. Banks frequently analyze <strong>customer savings, loan exposure, and portfolio strength</strong> using SQL.</p><p>This project, <strong>Customer Bank Accounts Analysis</strong>, demonstrates how <strong>SQL CTEs (Common Table Expressions) and Views</strong> can be used to perform <strong>structured, readable, and reusable analysis</strong> on banking data.</p><p>The project is designed from the perspective of a <strong>Business Analyst (BA)</strong> or <strong>Data Analyst (DA)</strong> working in a real banking environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hyYwc8BUnUwlMH2Jrz6V7w.png" /></figure><h3>🎯 Project Objectives</h3><p>The main objectives of this project are:</p><ul><li>Analyze customer savings and loan balances</li><li>Separate savings and loan exposure correctly</li><li>Identify customers with no loans</li><li>Identify high-loan and high-savings customers</li><li>Demonstrate practical use of <strong>CTEs and Views instead of complex subqueries</strong></li></ul><h3>🗂 Database Schema</h3><h3>Customers Table</h3><pre>CREATE TABLE Customers (<br>    CustomerID INT PRIMARY KEY,<br>    CustomerName VARCHAR(100),<br>    City VARCHAR(50),<br>    Phone VARCHAR(15)<br>);</pre><h3>Insert Customer Data</h3><pre>INSERT INTO Customers VALUES<br>(1,&#39;Amit Sharma&#39;,&#39;Delhi&#39;,&#39;9876543210&#39;),<br>(2,&#39;Neha Verma&#39;,&#39;Mumbai&#39;,&#39;9876543222&#39;),<br>(3,&#39;Rohit Singh&#39;,&#39;Pune&#39;,&#39;9876543333&#39;),<br>(4,&#39;Priya Patel&#39;,&#39;Ahmedabad&#39;,&#39;9876543444&#39;),<br>(5,&#39;Rahul Mehta&#39;,&#39;Bangalore&#39;,&#39;9876543555&#39;),<br>(6,&#39;Sneha Iyer&#39;,&#39;Chennai&#39;,&#39;9876543666&#39;),<br>(7,&#39;Vikas Gupta&#39;,&#39;Delhi&#39;,&#39;9876543777&#39;);</pre><h3>Accounts Table</h3><pre>CREATE TABLE Accounts (<br>    AccountID INT PRIMARY KEY,<br>    CustomerID INT,<br>    AccountType VARCHAR(20),     -- Savings / Loan<br>    SubType VARCHAR(20),         -- Salary, Regular, Home, Car, Personal<br>    Balance DECIMAL(12,2),<br>    CONSTRAINT FK_Accounts_Customers<br>    FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID)<br>);</pre><h3>Insert Account Data</h3><pre>INSERT INTO Accounts VALUES<br>(101,1,&#39;Savings&#39;,&#39;Salary&#39;,75000),<br>(102,1,&#39;Loan&#39;,&#39;Home&#39;,600000),<br>(103,2,&#39;Savings&#39;,&#39;Regular&#39;,45000),<br>(104,2,&#39;Loan&#39;,&#39;Car&#39;,300000),<br>(105,3,&#39;Savings&#39;,&#39;Salary&#39;,120000),<br>(106,4,&#39;Loan&#39;,&#39;Personal&#39;,150000),<br>(107,5,&#39;Savings&#39;,&#39;Regular&#39;,250000),<br>(108,5,&#39;Loan&#39;,&#39;Home&#39;,900000),<br>(109,6,&#39;Savings&#39;,&#39;Salary&#39;,90000),<br>(110,7,&#39;Savings&#39;,&#39;Regular&#39;,55000)</pre><h3>🔗 Step 1: Create Base View (Customer Portfolio)</h3><p>This view joins customers with their accounts and acts as a <strong>reusable reporting layer</strong>.</p><pre>CREATE VIEW [dbo].[vw_CustomerPortfolio]<br>AS<br>SELECT <br>    c.[CustomerID],<br>    c.[CustomerName],<br>    c.[City],<br>    a.[AccountType],<br>    a.[SubType],<br>    a.[Balance]<br>FROM [project3].[dbo].[Customers] c<br>JOIN [project3].[dbo].[Accounts] a<br>ON c.[CustomerID] = a.[CustomerID];</pre><h3>📊 Step 2: Separate Savings and Loan Balance Using CTE</h3><p>This CTE ensures savings and loan balances are <strong>never mixed</strong>, which is critical in banking analytics.</p><pre>WITH [BalanceSplit] AS (<br>    SELECT <br>        [CustomerID],<br>        SUM(CASE WHEN [AccountType] = &#39;Loan&#39; THEN [Balance] ELSE 0 END) AS [TotalLoanBalance],<br>        SUM(CASE WHEN [AccountType] = &#39;Savings&#39; THEN [Balance] ELSE 0 END) AS [TotalSavingsBalance]<br>    FROM [project3].[dbo].[Accounts]<br>    GROUP BY [CustomerID]<br>)<br>SELECT <br>    c.[CustomerName],<br>    b.[TotalSavingsBalance],<br>    b.[TotalLoanBalance]<br>FROM [BalanceSplit] b<br>JOIN [project3].[dbo].[Customers] c<br>ON b.[CustomerID] = c.[CustomerID];</pre><p><strong>Business Insight:</strong><br> Helps evaluate customer liquidity and credit exposure separately.</p><h3>💰 Step 3: Customers Whose Savings Are Greater Than Loans</h3><pre>WITH [BalanceSplit] AS (<br>    SELECT <br>        [CustomerID],<br>        SUM(CASE WHEN [AccountType] = &#39;Loan&#39; THEN [Balance] ELSE 0 END) AS [LoanBal],<br>        SUM(CASE WHEN [AccountType] = &#39;Savings&#39; THEN [Balance] ELSE 0 END) AS [SavBal]<br>    FROM [project3].[dbo].[Accounts]<br>    GROUP BY [CustomerID]<br>)<br>SELECT <br>    c.[CustomerName],<br>    b.[SavBal],<br>    b.[LoanBal]<br>FROM [BalanceSplit] b<br>JOIN [project3].[dbo].[Customers] c<br>ON b.[CustomerID] = c.[CustomerID]<br>WHERE b.[SavBal] &gt; b.[LoanBal];</pre><p><strong>Business Insight:</strong><br> Financially strong, low-risk customers.</p><h3>📌 Step 4: Create Customer Balance Summary View</h3><pre>CREATE VIEW [dbo].[vw_CustomerBalanceSummary]<br>AS<br>SELECT <br>    [CustomerID],<br>    SUM(CASE WHEN [AccountType] = &#39;Loan&#39; THEN [Balance] ELSE 0 END) AS [LoanBalance],<br>    SUM(CASE WHEN [AccountType] = &#39;Savings&#39; THEN [Balance] ELSE 0 END) AS [SavingsBalance]<br>FROM [project3].[dbo].[Accounts]<br>GROUP BY [CustomerID];</pre><p>This view simplifies reporting and dashboard creation.</p><h3>👤 Step 5: Display Customer Balances Using View</h3><pre>SELECT <br>    c.[CustomerName],<br>    v.[SavingsBalance],<br>    v.[LoanBalance]<br>FROM [dbo].[vw_CustomerBalanceSummary] v<br>JOIN [project3].[dbo].[Customers] c<br>ON v.[CustomerID] = c.[CustomerID];</pre><h3>🚫 Step 6: Customers With No Loan</h3><pre>SELECT <br>    c.[CustomerName],<br>    v.[SavingsBalance]<br>FROM [dbo].[vw_CustomerBalanceSummary] v<br>JOIN [project3].[dbo].[Customers] c<br>ON v.[CustomerID] = c.[CustomerID]<br>WHERE v.[LoanBalance] = 0;</pre><p><strong>Business Use Case:</strong><br> Cross-sell loan products.</p><h3>📈 Step 7: Customers With Loan Above Average Loan Balance</h3><pre>SELECT <br>    c.[CustomerName],<br>    v.[LoanBalance]<br>FROM [dbo].[vw_CustomerBalanceSummary] v<br>JOIN [project3].[dbo].[Customers] c<br>ON v.[CustomerID] = c.[CustomerID]<br>WHERE v.[LoanBalance] &gt;<br>(<br>    SELECT AVG([LoanBalance])<br>    FROM [dbo].[vw_CustomerBalanceSummary]<br>);</pre><p><strong>Business Use Case:</strong><br> Credit risk monitoring.</p><h3>💼 Step 8: High Savings Customers Using CTE + View</h3><pre>WITH [HighSavings] AS (<br>    SELECT *<br>    FROM [dbo].[vw_CustomerBalanceSummary]<br>    WHERE [SavingsBalance] &gt;<br>    (<br>        SELECT AVG([SavingsBalance])<br>        FROM [dbo].[vw_CustomerBalanceSummary]<br>    )<br>)<br>SELECT <br>    c.[CustomerName],<br>    h.[SavingsBalance]<br>FROM [HighSavings] h<br>JOIN [project3].[dbo].[Customers] c<br>ON h.[CustomerID] = c.[CustomerID];</pre><h3>🧠 Why CTEs and Views Are Better Than Subqueries</h3><ul><li>Cleaner logic</li><li>Better readability</li><li>Reusable queries</li><li>Industry-standard SQL practice</li></ul><p>Banks rely heavily on <strong>Views for reporting</strong> and <strong>CTEs for analysis</strong>.</p><h3>💼 Interview-Ready Summary</h3><blockquote><em>“In my Customer Bank Accounts Analysis project, I used SQL CTEs to separate savings and loan balances accurately and Views to create reusable reporting layers for banking analytics.”</em></blockquote><h3>🔚 Conclusion</h3><p>This project demonstrates how <strong>simple tables</strong>, combined with <strong>CTEs and Views</strong>, can produce <strong>powerful business insights</strong> in banking.</p><p>It reflects:<br> ✔ Real banking logic<br> ✔ Clean SQL practices<br> ✔ Strong analytical thinking</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2415ff4fe69" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Mastering SQL JOINs: Unlocking the Power of Relational Data]]></title>
            <link>https://medium.com/@sakhil1991/mastering-sql-joins-unlocking-the-power-of-relational-data-f5e6ef87409d?source=rss-62c052f29643------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5e6ef87409d</guid>
            <category><![CDATA[business-analytics]]></category>
            <category><![CDATA[data-analytics]]></category>
            <dc:creator><![CDATA[Akhil Sharma]]></dc:creator>
            <pubDate>Wed, 21 Jan 2026 02:01:40 GMT</pubDate>
            <atom:updated>2026-01-21T02:01:40.079Z</atom:updated>
            <content:encoded><![CDATA[<p>SQL JOINs are <strong>one of the most powerful tools</strong> in relational databases. They let us combine data from multiple tables to <strong>gain meaningful insights</strong>.</p><p>Whether you are a <strong>Business Analyst</strong>, <strong>Data Analyst</strong>, or a <strong>developer</strong>, understanding JOINs is essential for creating reports, dashboards, and analytics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2n3DUMNZKaBibCdw4hlpZg.png" /></figure><h3>📌 What is a JOIN?</h3><p>A <strong>JOIN</strong> in SQL is a method to combine rows from <strong>two or more tables</strong> based on a related column between them.</p><p>✅ <strong>Purpose:</strong></p><ul><li>Analyze relationships between tables</li><li>Aggregate data across tables</li><li>Generate actionable business insights</li></ul><p><strong>Example:</strong><br> In a retail scenario, if you want to know <strong>which customers bought which products</strong>, JOINs allow you to query both <strong>Customers</strong> and <strong>Orders</strong> tables together.</p><h3>📊Database Setup: Customers, Products &amp; Orders</h3><p>Before exploring JOINs, let’s <strong>create our tables</strong> and insert sample data.</p><h3>1️⃣ Create Customers Table</h3><pre>CREATE TABLE Customers (<br>    customer_id INT PRIMARY KEY,<br>    customer_name VARCHAR(100),<br>    city VARCHAR(50)<br>);</pre><pre>INSERT INTO Customers (customer_id, customer_name, city) VALUES<br>(1,&#39;Amit Sharma&#39;,&#39;Delhi&#39;),<br>(2,&#39;Riya Mehta&#39;,&#39;Mumbai&#39;),<br>(3,&#39;Rahul Verma&#39;,&#39;Pune&#39;),<br>(4,&#39;Sneha Kapoor&#39;,&#39;Bangalore&#39;),<br>(5,&#39;Vikram Singh&#39;,&#39;Chennai&#39;),<br>(6,&#39;Neha Joshi&#39;,&#39;Jaipur&#39;),<br>(7,&#39;Arjun Malhotra&#39;,&#39;Kolkata&#39;);</pre><h3>2️⃣ Create Products Table</h3><pre>CREATE TABLE Products (<br>    product_id INT PRIMARY KEY,<br>    product_name VARCHAR(100),<br>    category VARCHAR(50),<br>    price INT<br>);</pre><pre>INSERT INTO Products (product_id, product_name, category, price) VALUES<br>(101,&#39;Laptop&#39;,&#39;Electronics&#39;,55000),<br>(102,&#39;Mobile Phone&#39;,&#39;Electronics&#39;,30000),<br>(103,&#39;Headphones&#39;,&#39;Accessories&#39;,3000),<br>(104,&#39;Office Chair&#39;,&#39;Furniture&#39;,12000),<br>(105,&#39;Smart Watch&#39;,&#39;Electronics&#39;,15000),<br>(106,&#39;Tablet&#39;,&#39;Electronics&#39;,25000),<br>(107,&#39;Bluetooth Speaker&#39;,&#39;Accessories&#39;,5000);</pre><h3>3️⃣ Create Orders Table</h3><pre>CREATE TABLE Orders (<br>    order_id INT PRIMARY KEY,<br>    customer_id INT NOT NULL,<br>    product_id INT NOT NULL,<br>    quantity INT CHECK (quantity &gt; 0),<br>    order_date DATE,<br>    CONSTRAINT fk_customer FOREIGN KEY(customer_id) REFERENCES Customers(customer_id),<br>    CONSTRAINT fk_product FOREIGN KEY(product_id) REFERENCES Products(product_id)<br>);</pre><pre>INSERT INTO Orders (order_id, customer_id, product_id, quantity, order_date) VALUES<br>(1,1,101,1,&#39;2025-01-05&#39;),<br>(2,2,102,2,&#39;2025-01-06&#39;),<br>(3,3,103,3,&#39;2025-01-06&#39;),<br>(4,4,104,1,&#39;2025-01-07&#39;),<br>(5,5,105,2,&#39;2025-01-08&#39;),<br>(6,1,102,1,&#39;2025-01-09&#39;),<br>(7,2,103,2,&#39;2025-01-10&#39;),<br>(8,3,104,1,&#39;2025-01-11&#39;),<br>(9,4,105,2,&#39;2025-01-12&#39;),<br>(10,5,101,1,&#39;2025-01-13&#39;),<br>(11,1,103,2,&#39;2025-01-14&#39;),<br>(12,2,104,1,&#39;2025-01-15&#39;),<br>(13,3,105,1,&#39;2025-01-16&#39;),<br>(14,4,101,2,&#39;2025-01-17&#39;),<br>(15,5,102,1,&#39;2025-01-18&#39;),<br>(16,1,105,1,&#39;2025-01-19&#39;),<br>(17,2,101,1,&#39;2025-01-20&#39;),<br>(18,3,102,2,&#39;2025-01-21&#39;),<br>(19,4,103,1,&#39;2025-01-22&#39;),<br>(20,5,104,2,&#39;2025-01-23&#39;);</pre><h3>4️⃣ Relationship Between Tables</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*OxXgBSSnbSBQc06TETvCTg.jpeg" /></figure><h3>1️⃣ INNER JOIN</h3><p>Returns only rows where there is a <strong>match in both tables</strong>.</p><pre>SELECT o.order_id, c.customer_name, p.product_name, o.quantity, o.order_date<br>FROM Orders o<br>INNER JOIN Customers c ON o.customer_id = c.customer_id<br>INNER JOIN Products p ON o.product_id = p.product_id;</pre><p>💡 <strong>Insight:</strong> Shows only valid completed orders with customer and product details.</p><h3>2️⃣ LEFT JOIN</h3><p>Returns <strong>all rows from the left table</strong> and matching rows from the right table. Unmatched right table columns show NULL.</p><pre>SELECT c.customer_name, o.order_id, p.product_name, o.quantity<br>FROM Customers c<br>LEFT JOIN Orders o ON c.customer_id = o.customer_id<br>LEFT JOIN Products p ON o.product_id = p.product_id;</pre><p>💡 <strong>Insight:</strong> Shows <strong>all customers</strong>, even if they haven’t placed orders.</p><h3>3️⃣ RIGHT JOIN</h3><p>Returns <strong>all rows from the right table</strong> and matching rows from the left table.</p><pre>SELECT c.customer_name, o.order_id, p.product_name, o.quantity<br>FROM Customers c<br>RIGHT JOIN Orders o ON c.customer_id = o.customer_id<br>RIGHT JOIN Products p ON o.product_id = p.product_id;</pre><p>💡 <strong>Insight:</strong> Shows all <strong>orders</strong>, even if customer info is missing.</p><h3>4️⃣ FULL OUTER JOIN</h3><p>Returns <strong>all rows from both tables</strong>, with NULL for unmatched rows.</p><pre>SELECT c.customer_name, o.order_id, p.product_name, o.quantity<br>FROM Customers c<br>FULL OUTER JOIN Orders o ON c.customer_id = o.customer_id<br>FULL OUTER JOIN Products p ON o.product_id = p.product_id;</pre><p>💡 <strong>Insight:</strong> Provides a complete picture of customers, orders, and products.</p><h3>5️⃣ CROSS JOIN</h3><p>Returns a <strong>Cartesian product</strong> of both tables.</p><pre>SELECT c.customer_name, p.product_name<br>FROM Customers c<br>CROSS JOIN Products p;</pre><p>💡 <strong>Insight:</strong> Useful for forecasting potential purchases or recommendation analysis.</p><h3>6️⃣ SELF JOIN</h3><p>Joins a table with itself to <strong>compare rows within the same table</strong>.</p><pre>SELECT o1.order_id AS Order1, o2.order_id AS Order2,<br>       o1.customer_id, o1.product_id<br>FROM Orders o1<br>INNER JOIN Orders o2<br>  ON o1.customer_id = o2.customer_id<br> AND o1.product_id = o2.product_id<br> AND o1.order_id &lt; o2.order_id;</pre><p>💡 <strong>Insight:</strong> Finds repeat purchases by the same customer.</p><h3>7️⃣ Aggregation with JOIN</h3><p><strong>Total revenue per customer:</strong></p><pre>SELECT c.customer_name,<br>       SUM(o.quantity * p.price) AS total_revenue<br>FROM Orders o<br>INNER JOIN Customers c ON o.customer_id = c.customer_id<br>INNER JOIN Products p ON o.product_id = p.product_id<br>GROUP BY c.customer_name<br>ORDER BY total_revenue DESC;</pre><p>💡 <strong>Insight: </strong>Identifies <strong>high-value customers</strong>.</p><h3>8️⃣ Category-wise Business Performance</h3><pre>SELECT p.category AS Product_Category,<br>       SUM(o.quantity * p.price) AS Total_Revenue,<br>       COUNT(*) AS Total_Orders<br>FROM Orders o<br>INNER JOIN Products p<br>    ON o.product_id = p.product_id<br>GROUP BY p.category<br>ORDER BY Total_Revenue DESC;</pre><p>💡 <strong>Insight:</strong></p><ul><li>Shows revenue and demand per category.</li><li>Helps management prioritize inventory and marketing.</li><li>Enables strategic product planning.</li></ul><h3>✅ Key Takeaways</h3><ul><li>SQL JOINs connect multiple tables into meaningful datasets.</li><li>INNER, LEFT, RIGHT, FULL, CROSS, and SELF JOINs cover most real business scenarios.</li><li>JOINs with aggregation unlock advanced analytics like revenue, loyalty, and category performance.</li><li>Strong JOIN knowledge is essential for Business Analysts and Data Analysts.</li></ul><h3>🚀 Final Thought</h3><p>SQL JOINs are not just technical commands — they are <strong>business storytelling tools</strong>. With the right JOIN, you can convert scattered tables into insights that drive decisions, strategy, and growth.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5e6ef87409d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ SQL Keys & Constraints — Complete Guide for Beginners and Business Analysts]]></title>
            <link>https://medium.com/@sakhil1991/sql-keys-constraints-complete-guide-for-beginners-and-business-analysts-8a77443e5eb6?source=rss-62c052f29643------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a77443e5eb6</guid>
            <category><![CDATA[data-analyst]]></category>
            <category><![CDATA[business-analyst]]></category>
            <dc:creator><![CDATA[Akhil Sharma]]></dc:creator>
            <pubDate>Mon, 19 Jan 2026 18:11:39 GMT</pubDate>
            <atom:updated>2026-01-19T18:11:39.360Z</atom:updated>
            <content:encoded><![CDATA[<h3>🔐 SQL Keys &amp; Constraints — Complete Guide for Beginners and Business Analysts</h3><p>Keys and constraints are the <strong>foundation of relational databases</strong>. They ensure data integrity, uniqueness, and proper relationships between tables. Understanding them is essential for SQL, analytics, and Business Intelligence work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*raaCeEO9v6OZ90ni.png" /></figure><h3>1️⃣ What is a Key?</h3><p>A <strong>Key</strong> is a column or set of columns that uniquely identifies a record in a table or establishes relationships between tables.</p><h3>Why Keys are Important:</h3><ul><li>Prevent duplicate records</li><li>Enforce data integrity</li><li>Facilitate joins across tables</li><li>Support accurate reporting and analytics</li></ul><h3>2️⃣ Types of SQL Keys</h3><h3>🔹 1. Super Key</h3><ul><li><strong>Definition:</strong> Any combination of columns that uniquely identifies a row.</li><li><strong>Unique:</strong> ✅ Yes</li><li><strong>NULL Allowed:</strong> ❌ No</li><li><strong>Purpose:</strong> Identify records uniquely</li><li><strong>Example:</strong> {emp_id}, {email}, {emp_id + email}</li></ul><h3>🔹 2. Candidate Key</h3><ul><li><strong>Definition:</strong> Minimal Super Key without extra columns.</li><li><strong>Unique:</strong> ✅ Yes</li><li><strong>NULL Allowed:</strong> ❌ No</li><li><strong>Purpose:</strong> Potential Primary Key</li><li><strong>Example:</strong> emp_id, email</li></ul><h3>🔹 3. Primary Key</h3><ul><li><strong>Definition:</strong> Candidate Key chosen to uniquely identify records in a table.</li><li><strong>Unique:</strong> ✅ Yes</li><li><strong>NULL Allowed:</strong> ❌ No</li><li><strong>Purpose:</strong> Main identifier of a table</li><li><strong>Example:</strong> emp_id INT PRIMARY KEY</li></ul><h3>🔹 4. Alternate Key</h3><ul><li><strong>Definition:</strong> Candidate Key not chosen as Primary Key.</li><li><strong>Unique:</strong> ✅ Yes</li><li><strong>NULL Allowed:</strong> ❌ No</li><li><strong>Purpose:</strong> Secondary identifier</li><li><strong>Example:</strong> email (if emp_id is Primary Key)</li></ul><h3>🔹 5. Unique Key</h3><ul><li><strong>Definition:</strong> Ensures all non-NULL values in a column are unique.</li><li><strong>Unique:</strong> ✅ Yes</li><li><strong>NULL Allowed:</strong> ✅ Yes (depends on DBMS)</li><li><strong>Purpose:</strong> Prevent duplicate entries in optional columns</li><li><strong>Example:</strong> email VARCHAR(100) UNIQUE</li></ul><h3>🔹 6. Non-Unique Key</h3><ul><li><strong>Definition:</strong> Allows duplicate values; used mainly for indexing/searching.</li><li><strong>Unique:</strong> ❌ No</li><li><strong>NULL Allowed:</strong> ✅ Yes</li><li><strong>Purpose:</strong> Improves query performance and filtering</li><li><strong>Example:</strong> department column</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oHT1trXw7xHPd7b8" /></figure><h3>🔹 7. Foreign Key</h3><ul><li><strong>Definition:</strong> References Primary Key of another table to maintain referential integrity.</li><li><strong>Unique:</strong> ❌ No</li><li><strong>NULL Allowed:</strong> ✅ Yes</li><li><strong>Purpose:</strong> Create relationships and maintain data consistency</li><li><strong>Example:</strong> dept_id in Employees referencing Departments(dept_id)</li></ul><h3>🔹 8. Natural Key</h3><ul><li><strong>Definition:</strong> Real-world meaningful identifier.</li><li><strong>Unique:</strong> ✅ Yes</li><li><strong>NULL Allowed:</strong> ❌ No</li><li><strong>Purpose:</strong> Business identification</li><li><strong>Example:</strong> Email, PAN, Aadhaar</li></ul><h3>🔹 9. Surrogate Key</h3><ul><li><strong>Definition:</strong> Artificially generated identifier with no business meaning.</li><li><strong>Unique:</strong> ✅ Yes</li><li><strong>NULL Allowed:</strong> ❌ No</li><li><strong>Purpose:</strong> Simplifies relationships and improves performance</li><li><strong>Example:</strong> Auto-incremented emp_id</li></ul><h3>3️⃣ SQL Constraints</h3><p>Constraints enforce rules on data in tables. They are closely tied to keys</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*3PYLEJyhrde28EAb.jpeg" /></figure><h3>4️⃣ Properties of Keys and Constraints</h3><ul><li><strong>Uniqueness:</strong> No duplicate values allowed</li><li><strong>NOT NULL:</strong> Column must contain a value</li><li><strong>Referential Integrity:</strong> Foreign Keys reference valid rows</li><li><strong>Consistency:</strong> Ensures data correctness</li><li><strong>Performance:</strong> Helps indexing and fast retrieval</li></ul><h3>5️⃣ Real Project Example</h3><p><strong>Employee Management System</strong></p><pre>CREATE TABLE Departments (<br>  dept_id INT PRIMARY KEY,<br>  dept_name VARCHAR(50) UNIQUE<br>);</pre><pre>CREATE TABLE Employees (<br>  emp_id INT PRIMARY KEY,<br>  emp_name VARCHAR(50) NOT NULL,<br>  email VARCHAR(100) UNIQUE,<br>  dept_id INT,<br>  FOREIGN KEY (dept_id) REFERENCES Departments(dept_id)<br>);</pre><p><strong>Explanation:</strong></p><ul><li>emp_id → Primary, Surrogate</li><li>email → Unique, Natural</li><li>dept_id → Foreign Key</li><li>dept_name → Unique, Natural</li></ul><blockquote><em>This setup ensures no duplicate records, maintains relationships, and enforces data integrity.</em></blockquote><h3>6️⃣ Business Analyst Importance</h3><p>For a Business Analyst:</p><ul><li>Keys ensure <strong>accurate joins</strong> in queries</li><li>Constraints maintain <strong>clean, reliable data</strong></li><li>Enable <strong>trustworthy dashboards</strong> and reports</li><li>Prevent <strong>duplicate or invalid data</strong></li><li>Support <strong>scalable, maintainable data models</strong></li></ul><h3>7️⃣ Final Conclusion</h3><p>Keys and constraints form the <strong>backbone of relational databases</strong>. They are essential for ensuring uniqueness, integrity, and meaningful relationships in your data.</p><blockquote><em>“A table without keys is just a list. A table with keys and constraints becomes a powerful tool for analytics and decision-making.”</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a77443e5eb6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Mastering SQL: Queries and Subqueries with an Employee Management Project]]></title>
            <link>https://medium.com/@sakhil1991/mastering-sql-queries-and-subqueries-with-an-employee-management-project-2103bec6dc10?source=rss-62c052f29643------2</link>
            <guid isPermaLink="false">https://medium.com/p/2103bec6dc10</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[business-analytics]]></category>
            <category><![CDATA[data-analytics]]></category>
            <dc:creator><![CDATA[Akhil Sharma]]></dc:creator>
            <pubDate>Sun, 18 Jan 2026 07:15:44 GMT</pubDate>
            <atom:updated>2026-01-18T07:15:44.943Z</atom:updated>
            <content:encoded><![CDATA[<p>SQL (Structured Query Language) is the backbone of database management. Whether you are a beginner or a budding data analyst, mastering <strong>queries</strong> and <strong>subqueries</strong> is essential for extracting meaningful insights from your data.</p><p>In this article, we will explore <strong>what queries and subqueries are</strong>, their types, and how to use them with a <strong>real Employee Management project</strong>. By the end, you’ll not only understand the concepts but also see practical examples you can run immediately.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-EfsXvxjwwPdQoNhzIV62Q.png" /></figure><h3>🟠 Setting Up the Employee Management Project</h3><p>Before diving into queries, let’s <strong>create the table and insert employee data</strong> for our project.</p><h3>1. Create Table</h3><pre>CREATE TABLE Employees (<br>    emp_id INT PRIMARY KEY,<br>    emp_name VARCHAR(100),<br>    gender VARCHAR(10),<br>    department VARCHAR(50),<br>    designation VARCHAR(50),<br>    join_date DATE,<br>    experience_years INT,<br>    salary INT<br>);</pre><h3>2. Insert Employee Records</h3><pre>INSERT INTO [project1].[dbo].[Employees]<br>([emp_id],[emp_name],[gender],[department],[designation],[join_date],[experience_years],[salary])<br>VALUES<br>(1,&#39;Rahul&#39;,&#39;Male&#39;,&#39;IT&#39;,&#39;Developer&#39;,&#39;2020-01-10&#39;,5,60000),<br>(2,&#39;Neha&#39;,&#39;Female&#39;,&#39;HR&#39;,&#39;Manager&#39;,&#39;2019-03-15&#39;,7,75000),<br>(3,&#39;Amit&#39;,&#39;Male&#39;,&#39;Finance&#39;,&#39;Analyst&#39;,&#39;2021-06-01&#39;,3,50000),<br>(4,&#39;Pooja&#39;,&#39;Female&#39;,&#39;IT&#39;,&#39;Tester&#39;,&#39;2022-02-20&#39;,2,45000),<br>(5,&#39;Ravi&#39;,&#39;Male&#39;,&#39;Finance&#39;,&#39;Manager&#39;,&#39;2018-08-10&#39;,9,90000),<br>...<br>(50,&#39;Anu&#39;,&#39;Female&#39;,&#39;Finance&#39;,&#39;Analyst&#39;,&#39;2020-11-11&#39;,5,60000);</pre><blockquote><em>✅ Tip: This table represents a realistic employee dataset, perfect for practicing SQL queries and subqueries.</em></blockquote><h3>🟢 What is a Query in SQL?</h3><p>A <strong>query</strong> is a SQL statement used to <strong>retrieve, insert, update, or delete data</strong> from a database.</p><p><strong>Definition:</strong></p><blockquote><em>A query is a SQL statement used to communicate with a database to retrieve or manipulate data.</em></blockquote><p>Queries form the foundation of SQL. Starting with simple queries helps you <strong>explore your data</strong> and prepare for more complex operations.</p><h3>🔹 Simple Query Examples</h3><ol><li><strong>All employees from IT department:</strong></li></ol><pre>SELECT *<br>FROM [project1].[dbo].[Employees]<br>WHERE [DEPARTMENT] = &#39;IT&#39;;</pre><p>2. <strong>List all distinct departments:</strong></p><pre>SELECT DISTINCT [DEPARTMENT]<br>FROM [project1].[dbo].[Employees];</pre><p><strong>3. Employees with salary &gt; 60,000 in ascending order:</strong></p><pre>SELECT *<br>FROM [project1].[dbo].[Employees]<br>WHERE [SALARY] &gt; 60000<br>ORDER BY SALARY;</pre><p><strong>4. Department-wise employee count:</strong></p><pre>SELECT [DEPARTMENT], COUNT(*) AS TOTAL_EMP<br>FROM [project1].[dbo].[Employees]<br>GROUP BY [DEPARTMENT];</pre><p><strong>5. Top 10 highest-paid employees:</strong></p><pre>SELECT TOP 10 *<br>FROM [project1].[dbo].[Employees]<br>ORDER BY SALARY DESC;</pre><blockquote><em>✅ Tip: Simple queries are essential for exploring datasets and forming the base for advanced SQL operations.</em></blockquote><h3>🟡 What is a Subquery in SQL?</h3><p>A <strong>subquery</strong> is a query <strong>nested inside another query</strong>, whose results are used by the outer query. Subqueries allow <strong>dynamic filtering, aggregation, and comparisons</strong>, making them powerful tools for complex analysis.</p><p><strong>Definition:</strong></p><blockquote><em>A subquery is a SQL query embedded inside another query, whose result is used by the outer query.</em></blockquote><h3>🔹 Types of Subqueries</h3><p>Here’s a detailed explanation of <strong>all subquery types</strong>, with examples from the Employee Management project:</p><h3>🔹 Simple Subquery</h3><ul><li>Returns a <strong>single value</strong>.</li><li>Often used with = or comparison operators.</li></ul><p>🔸<strong>Example:</strong> Employees earning more than the <strong>average salary</strong>:</p><pre>SELECT *<br>FROM [project1].[dbo].[Employees]<br>WHERE SALARY &gt; (SELECT AVG(SALARY) FROM [project1].[dbo].[Employees]);</pre><p>👉 The subquery calculates the <strong>average salary</strong> of all employees and the outer query selects employees whose salary is <strong>greater than that average</strong>.</p><h3>🔹Multiple-Row Subquery</h3><p>A <strong>multiple-row subquery</strong> returns <strong>more than one value</strong>. It is commonly used with operators such as:</p><ul><li>IN</li><li>ANY</li><li>ALL</li></ul><p>This type of subquery is useful when the condition depends on a <strong>set of results</strong> rather than a single value.</p><p>🔸<strong>Example:</strong> Employees in departments having <strong>more than 10 employees</strong>:</p><pre>SELECT *<br>FROM [project1].[dbo].[Employees]<br>WHERE [department] IN (<br>    SELECT DEPARTMENT<br>    FROM [project1].[dbo].[Employees]<br>    GROUP BY [DEPARTMENT]<br>    HAVING COUNT(*) &gt; 10<br>)<br>ORDER BY DEPARTMENT;</pre><p>👉 The inner query finds departments with more than 10 employees and the outer query retrieves all employees working in those departments.</p><h3>🔹Correlated Subquery</h3><ul><li>A <strong>correlated subquery</strong> is a special type of subquery that depends on the outer query for its execution. Unlike simple subqueries, it is <strong>evaluated once for each row</strong> processed by the main query.</li><li>Because of this dependency, correlated subqueries are extremely powerful for performing <strong>row-by-row comparisons</strong>, especially when working with grouped or categorized data.</li></ul><p>🔸<strong>Example:</strong> Highest-paid employee in each department:</p><pre>SELECT *<br>FROM [project1].[dbo].[Employees] E<br>WHERE E.SALARY = (<br>    SELECT MAX(SALARY)<br>    FROM [project1].[dbo].[Employees]<br>    WHERE DEPARTMENT = E.DEPARTMENT<br>);</pre><p>🔸<strong>Example:</strong> Employees earning more than their <strong>department average salary</strong>:</p><pre>SELECT *<br>FROM [project1].[dbo].[Employees] E<br>WHERE E.SALARY &gt; (<br>    SELECT AVG(SALARY)<br>    FROM [project1].[dbo].[Employees]<br>    WHERE DEPARTMENT = E.DEPARTMENT<br>);</pre><p>👉 In both examples, the outer query evaluates one employee record at a time. For each record, the inner query calculates the maximum or average salary for that employee’s department. If the employee’s salary matches the calculated value, the record is returned. This evaluation continues row by row until all employee records are processed.</p><h3>🔹 Derived Table Subquery (Subquery in FROM Clause)</h3><p>A <strong>derived table subquery</strong> is a subquery written inside the FROM clause. The result of this subquery behaves like a <strong>temporary table</strong> that can be queried by the outer SQL statement.</p><p><strong>🔸 Example 1: </strong>Sort Employees by Salary using<strong> Derived Table</strong></p><pre>SELECT *<br>FROM (<br>    SELECT EMP_NAME, DEPARTMENT, SALARY<br>    FROM [project1].[dbo].[Employees]<br>) AS T<br>ORDER BY SALARY;</pre><p>👉 Here, the inner query creates a temporary table T, and the outer query sorts it by salary.</p><p><strong>🔸 Example 2: </strong>Show Each Employee with Their<strong> Department Average Salary</strong></p><pre>SELECT EMP_NAME, E.DEPARTMENT, SALARY, AVG_SAL<br>FROM (<br>    SELECT DEPARTMENT, AVG(SALARY) AS AVG_SAL<br>    FROM [project1].[dbo].[Employees]<br>    GROUP BY DEPARTMENT<br>) AS T1<br>JOIN [project1].[dbo].[Employees] E<br>ON T1.DEPARTMENT = E.DEPARTMENT;</pre><p>👉 This helps compare each employee’s salary with their department’s average salary.</p><p><strong>🔸 Example 3: </strong>Show Each Employee with Company<strong> Average Salary (CROSS JOIN)</strong></p><p><strong>Way 1</strong></p><pre>SELECT EMP_NAME, DEPARTMENT, SALARY, AVG_SAL<br>FROM (<br>    SELECT AVG(SALARY) AS AVG_SAL<br>    FROM [project1].[dbo].[Employees]<br>) AS T1<br>CROSS JOIN [project1].[dbo].[Employees] E<br>ORDER BY DEPARTMENT;</pre><p><strong>Way 2</strong></p><pre>SELECT EMP_NAME, DEPARTMENT, SALARY, AVG_SAL<br>FROM (<br>    SELECT AVG(SALARY) AS AVG_SAL<br>    FROM [project1].[dbo].[Employees]<br>) AS T1<br>JOIN [project1].[dbo].[Employees] E<br>ON 1 = 1<br>ORDER BY DEPARTMENT;</pre><p>👉 Both methods attach the company average salary to every employee record.</p><h3>🔹 Scalar Subquery</h3><p>A <strong>scalar subquery</strong> returns exactly <strong>one value</strong> and is commonly used in the SELECT clause.</p><p><strong>🔸 Example 1</strong>: Show Each Employee with <strong>Company Average Salary</strong></p><pre>SELECT *, (<br>    SELECT AVG(SALARY)<br>    FROM [project1].[dbo].[Employees]<br>) AS AVG_SALARY<br>FROM [project1].[dbo].[Employees];</pre><p>👉 Each row now shows the employee’s salary along with the company average salary.</p><p><strong>🔸 Example 2: </strong>Show Each Employee with Their <strong>Department Average Salary</strong></p><pre>SELECT *, (<br>    SELECT AVG(SALARY)<br>    FROM [project1].[dbo].[Employees]<br>    WHERE DEPARTMENT = E.DEPARTMENT<br>) AS AVG_SALARY<br>FROM [project1].[dbo].[Employees] E<br>ORDER BY DEPARTMENT;</pre><p>👉 This helps compare each employee’s salary with their department’s average.</p><h3>🔹 Nested Subquery</h3><p>A <strong>nested subquery</strong> is a subquery inside another subquery. It is used for solving complex analytical problems.</p><p><strong>Definition:</strong><br>A nested subquery is a subquery written inside another subquery, forming multiple levels of SQL logic.</p><p><strong>🔸 Example:</strong> Employees from the Department with <strong>Highest Average Salary</strong></p><pre>SELECT *<br>FROM [project1].[dbo].[Employees]<br>WHERE department = (<br>    SELECT department<br>    FROM [project1].[dbo].[Employees]<br>    GROUP BY department<br>    HAVING AVG(salary) = (<br>        SELECT MAX(AvgSal)<br>        FROM (<br>            SELECT AVG(salary) AS AvgSal<br>            FROM [project1].[dbo].[Employees]<br>            GROUP BY department<br>        ) t<br>    )<br>);</pre><p>👉 This query works in three layers:</p><ol><li>Inner subquery calculates average salary per department.</li><li>Middle subquery finds the maximum of those averages.</li><li>Outer query returns employees from that top-paying department.</li></ol><h3>🟣 Conclusion</h3><p>Mastering <strong>queries and subqueries</strong> is essential for any data professional. Simple queries help you <strong>understand and explore data</strong>, while subqueries allow <strong>complex, dynamic analysis</strong> such as comparing salaries, aggregating department statistics, or finding top performers.</p><p>Using your <strong>Employee Management project</strong>, you now have a <strong>practical, hands-on understanding</strong> of SQL concepts and how they apply in real-world scenarios.</p><h3>💡 What’s Next: Advanced SQL Ideas</h3><p>Once you’re comfortable with queries and subqueries, you can try:</p><ul><li><strong>Joins and Multi-table Analysis</strong> — Analyze employees with department or project tables.</li><li><strong>Window Functions</strong> — Calculate running totals, ranks, or department-wise percentiles.</li><li><strong>Stored Procedures &amp; Functions</strong> — Automate common reports like payroll or performance summaries.</li><li><strong>Dynamic Reporting</strong> — Combine subqueries with grouping, filtering, and conditional logic for dashboards.</li><li><strong>Data Analysis Projects</strong> — Extend the Employee project to include attendance, performance, or salary hikes for advanced analytics.</li></ul><blockquote><em>💡 Tip: Always start with </em><strong><em>simple queries</em></strong><em>, then gradually incorporate </em><strong><em>subqueries, joins, and window functions</em></strong><em> for deeper insights.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2103bec6dc10" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Banking Transaction Analyzer Using Python (Google Colab)]]></title>
            <link>https://medium.com/@sakhil1991/banking-transaction-analyzer-using-python-google-colab-5c4b538be431?source=rss-62c052f29643------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c4b538be431</guid>
            <category><![CDATA[business-analyst]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Akhil Sharma]]></dc:creator>
            <pubDate>Sun, 04 Jan 2026 12:40:02 GMT</pubDate>
            <atom:updated>2026-01-04T12:42:11.156Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong><em>A Python Project Implemented in Three Different Ways for comparing and understanding use cases of different data types</em></strong></blockquote><h3>📘 Introduction</h3><p>Transaction analysis is a core activity in the banking and financial services industry. From tracking deposits and withdrawals to identifying high-value transactions, such analysis supports decision-making, compliance, and customer insights.</p><p>The <strong>Banking Transaction Analyzer</strong> is a Python-based project developed on <strong>Google Colab</strong>. What makes this project unique is that the <strong>same business problem is solved using three different Python approaches</strong>, helping learners understand not just <em>what</em> the solution is, but <em>how</em> code quality and structure improve with better design.</p><p>This project is especially useful for <strong>Business Analysts and Data Analysts</strong> who are learning Python with real-world banking use cases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_qDEIL0Pb9hG_FO2cm6Brg.png" /></figure><h3>🎯 Project Objectives</h3><ul><li>Analyze banking transaction data</li><li>Calculate total deposits and withdrawals</li><li>Compute account balance</li><li>Count deposit and withdrawal transactions</li><li>Identify high-value transactions</li><li>Compare different Python implementation styles</li></ul><h3>🔁 Three Different Implementation Approaches</h3><p>One of the key highlights of this project is that it is implemented in <strong>three different ways</strong>, each demonstrating a different level of Python understanding and coding maturity.</p><h3>🧩 Way 1: Simple If-Else Based Logic</h3><h3>🔍 Description</h3><p>In the first approach, the entire logic is written using:</p><ul><li>Basic variables</li><li>for loop</li><li>if-else conditions</li><li>A list to store high-value transactions</li></ul><p>All calculations are done directly inside the loop.</p><pre># Banking Transaction Analyzer<br><br># Way 1 Using simple if else conditions<br>&quot;&quot;&quot;<br>Work Flow:<br>1-&gt; Create Summary variables and initialize with zero<br>2-&gt; Use for loop and if else statement to update variables<br>3-&gt; Create High Value list and append it if high value transaction exists<br>4-&gt; Print the output<br>&quot;&quot;&quot;<br># Transactions: (date, type, amount, description)<br>transactions = [<br>    (&quot;2025-01-01&quot;, &quot;deposit&quot;, 50000, &quot;Salary&quot;),<br>    (&quot;2025-01-05&quot;, &quot;withdrawal&quot;, 8000, &quot;ATM&quot;),<br>    (&quot;2025-01-10&quot;, &quot;withdrawal&quot;, 12000, &quot;Rent&quot;),<br>    (&quot;2025-01-15&quot;, &quot;deposit&quot;, 15000, &quot;Freelance&quot;),<br>    (&quot;2025-01-20&quot;, &quot;withdrawal&quot;, 30000, &quot;Shopping&quot;),<br>    (&quot;2025-01-25&quot;, &quot;withdrawal&quot;, 2000, &quot;Recharge&quot;)<br>]<br><br>total_deposit = 0<br>total_withdrawal = 0<br><br>deposit_count = 0<br>withdrawal_count = 0<br><br>high_value = []<br><br># Loop through transactions<br>for t in transactions:<br>    date, t_type, amount, desc = t<br><br>    if t_type == &quot;deposit&quot;:<br>        total_deposit += amount<br>        deposit_count += 1<br>    else:<br>        total_withdrawal += amount<br>        withdrawal_count += 1<br><br>    if amount &gt;= 20000:<br>        high_value.append(t)<br><br>balance = total_deposit - total_withdrawal<br><br># -------------------------------<br># OUTPUT<br># -------------------------------<br>print(&quot;----- BANK TRANSACTION SUMMARY -----&quot;)<br>print(&quot;Total Deposit :&quot;, total_deposit)<br>print(&quot;Total Withdrawal :&quot;, total_withdrawal)<br>print(&quot;Balance :&quot;, balance)<br><br>print(&quot;\n----- TRANSACTION COUNT -----&quot;)<br>print(&quot;Deposit :&quot;, deposit_count)<br>print(&quot;Withdrawal :&quot;, withdrawal_count)<br><br>print(&quot;\n----- HIGH VALUE TRANSACTIONS -----&quot;)<br>if high_value:<br>  for t in high_value:<br>    print(t)<br>else:<br>  print(&quot;No high value transactions found&quot;)</pre><h3>🎯 Why This Approach?</h3><ul><li>Best for Python beginners</li><li>Helps understand loops and conditions clearly</li><li>Easy to follow</li></ul><h3>🧩 Way 2: Functions with List &amp; Tuple</h3><h3>🔍 Description</h3><p>The same problem is solved using functions:</p><ul><li>Summary function returns values as a tuple</li><li>High-value function returns a list</li><li>Tuple unpacking is used in the main program</li></ul><pre><br># Banking Transaction Analyzer<br><br># Way 2 Using List and Tuple<br>&quot;&quot;&quot;<br>Work Flow:<br>1-&gt; Create Summary function <br>2-&gt; Extract Infornation and return in the form of tuple<br>3-&gt; Create function to find High Value Transactions and store in a list<br>4-&gt; Write main program to link values by unpacking tuple and get output<br>&quot;&quot;&quot;<br><br># List of transactions (date, type, amount, description)<br>transactions = [<br>    (&quot;2025-01-01&quot;, &quot;deposit&quot;, 50000, &quot;Salary&quot;),<br>    (&quot;2025-01-05&quot;, &quot;withdrawal&quot;, 8000, &quot;ATM&quot;),<br>    (&quot;2025-01-10&quot;, &quot;withdrawal&quot;, 12000, &quot;Rent&quot;),<br>    (&quot;2025-01-15&quot;, &quot;deposit&quot;, 15000, &quot;Freelance&quot;),<br>    (&quot;2025-01-20&quot;, &quot;withdrawal&quot;, 30000, &quot;Shopping&quot;),<br>    (&quot;2025-01-25&quot;, &quot;withdrawal&quot;, 2000, &quot;Recharge&quot;)<br>]<br><br># -------------------------------<br># Function: Transaction Summary<br># -------------------------------<br>def transaction_summary():<br>    total_deposit = 0<br>    total_withdrawal = 0<br>    deposit_count = 0<br>    withdrawal_count = 0<br><br>    for t in transactions:<br>        if t[1] == &quot;deposit&quot;:<br>            total_deposit += t[2]<br>            deposit_count += 1<br>        else:<br>            total_withdrawal += t[2]<br>            withdrawal_count += 1<br><br>    balance = total_deposit - total_withdrawal<br>    return (total_deposit, total_withdrawal, balance, deposit_count, withdrawal_count)<br><br><br># -------------------------------<br># Function: High Value Transactions<br># -------------------------------<br>def get_high_value(transactions, limit=20000):<br>    high_value = []<br><br>    for t in transactions:<br>        if t[2] &gt;= limit:<br>            high_value.append(t)<br><br>    return high_value<br><br># -------------------------------<br># MAIN PROGRAM<br># -------------------------------<br><br>total_dep, total_wd, balance,deposit_count, withdrawal_count = transaction_summary()<br><br>high_value_txns = get_high_value(transactions)<br><br># -------------------------------<br># OUTPUT<br># -------------------------------<br>print(&quot;\n----- BANK TRANSACTION SUMMARY -----&quot;)<br>print(&quot;Total Deposit :&quot;, total_dep)<br>print(&quot;Total Withdrawal :&quot;, total_wd)<br>print(&quot;Balance :&quot;, balance)<br><br>print(&quot;\n----- TRANSACTION COUNT -----&quot;)<br>print(&quot;Deposit :&quot;, deposit_count)<br>print(&quot;Withdrawal :&quot;, withdrawal_count)<br><br>print(&quot;\n----- HIGH VALUE TRANSACTIONS -----&quot;)<br>if high_value_txns:<br>    for t in high_value_txns:<br>        print(t)<br>else:<br>    print(&quot;No high value transactions found&quot;)</pre><h3>🎯 Why This Way?</h3><ul><li>Cleaner and reusable code</li><li>Improves readability</li></ul><h3>🧩 Way 3: Functions with Dictionary (Best Practice)</h3><h3>🔍 Description</h3><p>In this approach:</p><ul><li>Results are stored in a dictionary</li><li>Keys represent business metrics</li><li>Output looks like a report or API response</li></ul><pre># Banking Transaction Analyzer<br><br># Way 3 Using List and Dictionary<br>&quot;&quot;&quot;<br>Work Flow:<br>1-&gt; Create Summary function <br>2-&gt; Extract Infornation and return in the form of Dictionary<br>3-&gt; Create function to find High Value Transactions and store in a list<br>4-&gt; Write main program to link values by unpacking tuple and get output<br>&quot;&quot;&quot;<br><br># List of transactions (date, type, amount, description)<br>transactions = [<br>    (&quot;2025-01-01&quot;, &quot;deposit&quot;, 50000, &quot;Salary&quot;),<br>    (&quot;2025-01-05&quot;, &quot;withdrawal&quot;, 8000, &quot;ATM&quot;),<br>    (&quot;2025-01-10&quot;, &quot;withdrawal&quot;, 12000, &quot;Rent&quot;),<br>    (&quot;2025-01-15&quot;, &quot;deposit&quot;, 15000, &quot;Freelance&quot;),<br>    (&quot;2025-01-20&quot;, &quot;withdrawal&quot;, 30000, &quot;Shopping&quot;),<br>    (&quot;2025-01-25&quot;, &quot;withdrawal&quot;, 2000, &quot;Recharge&quot;)<br>]<br><br># -------------------------------<br># Function: Transaction Summary<br># -------------------------------<br>def transaction_summary():<br>  summary =  {&quot;Total Deposit&quot;:0, &quot;Total Withdrawal&quot;:0, <br>              &quot;Balance&quot;:0, &quot;Deposit Count&quot;:0, &quot;Withdrawal Count&quot;:0}<br><br>  for t in transactions:<br>        if t[1] == &quot;deposit&quot;:<br>            summary[&quot;Total Deposit&quot;] += t[2]<br>            summary[&quot;Deposit Count&quot;] += 1<br>        elif t[1] == &quot;withdrawal&quot;:<br>            summary[&quot;Total Withdrawal&quot;] += t[2]<br>            summary[&quot;Withdrawal Count&quot;] += 1<br>  summary[&quot;Balance&quot;] = summary[&quot;Total Deposit&quot;] - summary[&quot;Total Withdrawal&quot;]<br>  return summary<br><br><br><br># -------------------------------<br># Function: High Value Transactions<br># -------------------------------<br>def get_high_value(transactions, limit=20000):<br>    high_value = []<br><br>    for t in transactions:<br>        if t[2] &gt;= limit:<br>            high_value.append(t)<br><br>    return high_value<br><br># -------------------------------<br># MAIN PROGRAM<br># -------------------------------<br>txn_summary = transaction_summary()<br>high_value_txn = get_high_value(transactions)<br><br>print(&quot;----- BANK TRANSACTION SUMMARY -----&quot;)<br>for key, value in txn_summary.items():<br>    print(key, &quot;:&quot;, value)<br><br>print(&quot;\n----- HIGH VALUE TRANSACTIONS -----&quot;)<br><br>if high_value_txn:<br>    for t in high_value_txn:<br>        print(t)<br>else:<br>    print(&quot;No high value transactions found&quot;)</pre><h3>🎯 Why This Way?</h3><ul><li>Closest to real-world analytics projects</li><li>Easy to extend and integrate</li><li>Ideal for dashboards and reports</li></ul><h3>🧠 Key Python Concepts Used</h3><ul><li>Lists, Tuples, Dictionaries</li><li>Functions &amp; return values</li><li>Loops and conditional statements</li><li>Financial calculations</li><li>Code comparison &amp; optimization</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c4b538be431" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Rock Paper Scissors Game in Python Using Functions (Google Colab Project)]]></title>
            <link>https://medium.com/@sakhil1991/building-a-rock-paper-scissors-game-in-python-using-functions-google-colab-project-7afe69c0014a?source=rss-62c052f29643------2</link>
            <guid isPermaLink="false">https://medium.com/p/7afe69c0014a</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Akhil Sharma]]></dc:creator>
            <pubDate>Sun, 04 Jan 2026 06:23:54 GMT</pubDate>
            <atom:updated>2026-01-04T06:37:58.851Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>By Akhil Sharma</strong></p><p>Rock Paper Scissors is one of the most popular beginner-friendly games used to understand programming fundamentals. In this article, I will walk through a <strong>Python-based Rock Paper Scissors project</strong> that I built using <strong>functions, loops, conditional statements, and modules</strong> in <strong>Google Colab</strong>.</p><p>This project is interactive, supports <strong>multiple rounds</strong>, maintains a <strong>scorecard</strong>, and introduces a <strong>time delay</strong> to make the gameplay more realistic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8mn2l0cazBoKederv9q1gA.png" /></figure><h3>🎯 Project Objective</h3><p>The main objectives of this project are:</p><ul><li>To practice <strong>function-based programming</strong> in Python</li><li>To work with <strong>user inputs and validations</strong></li><li>To use the <strong>random module</strong> for computer-generated choices</li><li>To apply <strong>conditional statements</strong> for game logic</li><li>To track scores across multiple rounds</li></ul><p>This project is ideal for <strong>Python beginners</strong> and anyone looking to strengthen their logical thinking skills.</p><h3>🧩 Project Workflow</h3><p>The game follows a structured and easy-to-understand workflow:</p><ol><li>Ask the player how many rounds they want to play</li><li>For each round:</li></ol><ul><li>Take input from the player (Rock, Paper, or Scissors)</li><li>Generate a random choice for the computer</li><li>Compare both choices</li><li>Decide the winner of the round</li><li>Update the scorecard.</li></ul><p>3. After all rounds are completed:</p><ul><li>Display the final scores</li><li>Declare the overall winner</li></ul><p>This modular flow makes the program readable, reusable, and easy to extend.</p><h3>🧠 Game Logic Overview</h3><p>The decision-making logic follows standard Rock Paper Scissors rules:</p><ul><li><strong>Rock beats Scissors</strong></li><li><strong>Scissors beats Paper</strong></li><li><strong>Paper beats Rock</strong></li><li>Same choices result in a <strong>Tie</strong></li></ul><p>Based on each round’s outcome, the program updates:</p><ul><li>Player score</li><li>Computer score</li><li>Tie count</li></ul><h3>🧑‍💻 Code Implementation</h3><p>Below is the complete implementation of the <strong>Rock Paper Scissors game</strong> written in Python using functions.</p><pre># Rock Paper Scissors Game<br><br>&quot;&quot;&quot;<br>Project Workflow:<br>For N number of rounds:<br>  -&gt; Input from Player (Rock, Paper, Scissors)<br>  -&gt; Input from Computer (Random choice)<br>  -&gt; Compare Player and Computer inputs<br>  -&gt; Decide the winner<br>  -&gt; Update scorecard<br>-&gt; Display final score<br>&quot;&quot;&quot;<br><br># Import required modules<br>import random<br>import time<br><br><br># Function to take player choice<br>def get_player_choice():<br>    print(&quot;------------------------------&quot;)<br>    print(&quot;      Pick your Choice&quot;)<br>    print(&quot;------------------------------&quot;)<br>    print(&quot;Your Choices are:&quot;)<br>    print(&quot;1. Rock&quot;)<br>    print(&quot;2. Paper&quot;)<br>    print(&quot;3. Scissors&quot;)<br>    print(&quot;------------------------------&quot;)<br><br>    choice = int(input(&quot;Enter your choice: &quot;))<br>    print(&quot;------------------------------&quot;)<br><br>    if choice == 1:<br>        return &quot;Rock&quot;<br>    elif choice == 2:<br>        return &quot;Paper&quot;<br>    elif choice == 3:<br>        return &quot;Scissors&quot;<br>    else:<br>        print(&quot;Invalid choice! Please enter again.&quot;)<br>        return get_player_choice()<br><br><br># Function to generate computer choice<br>def get_computer_choice():<br>    possible_moves = [&quot;Rock&quot;, &quot;Paper&quot;, &quot;Scissors&quot;]<br>    return random.choice(possible_moves)<br><br><br># Main function to play the game<br>def play_game():<br>    print(&quot;-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-&quot;)<br>    print(&quot;|    ROCK PAPER SCISSORS      |&quot;)<br>    print(&quot;-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-&quot;)<br><br>    rounds = int(input(&quot;How many rounds do you want to play? &quot;))<br>    print(&quot;\nGame Starting...\n&quot;)<br>    time.sleep(2)<br><br>    # Score variables<br>    player_score = 0<br>    computer_score = 0<br>    tie_score = 0<br><br>    # Game loop<br>    for round_num in range(1, rounds + 1):<br>        print(&quot;-------------------------------&quot;)<br>        print(&quot;         Round &gt;&quot;, round_num)<br><br>        player_choice = get_player_choice()<br>        computer_choice = get_computer_choice()<br><br>        print(&quot;Player choice:&quot;, player_choice)<br>        print(&quot;Computer choice:&quot;, computer_choice)<br><br>        if player_choice == computer_choice:<br>            print(&quot;Oops, it&#39;s a Tie!&quot;)<br>            tie_score += 1<br>        elif player_choice == &quot;Rock&quot; and computer_choice == &quot;Scissors&quot;:<br>            print(&quot;Yeah, You won!&quot;)<br>            player_score += 1<br>        elif player_choice == &quot;Rock&quot; and computer_choice == &quot;Paper&quot;:<br>            print(&quot;Ohh, Computer won!&quot;)<br>            computer_score += 1<br>        elif player_choice == &quot;Paper&quot; and computer_choice == &quot;Rock&quot;:<br>            print(&quot;Yeah, You won!&quot;)<br>            player_score += 1<br>        elif player_choice == &quot;Paper&quot; and computer_choice == &quot;Scissors&quot;:<br>            print(&quot;Ohh, Computer won!&quot;)<br>            computer_score += 1<br>        elif player_choice == &quot;Scissors&quot; and computer_choice == &quot;Paper&quot;:<br>            print(&quot;Yeah, You won!&quot;)<br>            player_score += 1<br>        elif player_choice == &quot;Scissors&quot; and computer_choice == &quot;Rock&quot;:<br>            print(&quot;Ohh, Computer won!&quot;)<br>            computer_score += 1<br><br>        print(&quot;------------------------------------&quot;)<br>        print(&quot;Player Score -&gt;&quot;, player_score)<br>        print(&quot;Computer Score -&gt;&quot;, computer_score)<br>        print(&quot;Tie Score -&gt;&quot;, tie_score)<br>        print(&quot;------------------------------------&quot;)<br>        time.sleep(2)<br><br>    # Final score display<br>    print(&quot;-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-&quot;)<br>    print(&quot;|       Final Score Time      |&quot;)<br>    print(&quot;-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-&quot;)<br>    print(&quot;\nPlayer Score -&gt;&quot;, player_score)<br>    print(&quot;Computer Score -&gt;&quot;, computer_score)<br>    print(&quot;Tie Score -&gt;&quot;, tie_score)<br>    print(&quot;-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-&quot;)<br><br>    if player_score &gt; computer_score:<br>        print(&quot;You won the Game!&quot;)<br>    elif player_score &lt; computer_score:<br>        print(&quot;Computer won the Game!&quot;)<br>    else:<br>        print(&quot;Game is a Tie!&quot;)<br><br>    print(&quot;-------------------------------&quot;)<br><br><br># Run the game<br>play_game()</pre><h3>🛠️ Tools and Technologies Used</h3><ul><li><strong>Programming Language:</strong> Python</li><li><strong>Platform:</strong> Google Colab</li><li><strong>Python Modules Used:</strong></li><li>random → To generate the computer’s move randomly</li><li>time → To add delays between rounds for better user experience</li></ul><h3>🔧 Explanation of Key Functions</h3><h3>1️⃣ get_player_choice()</h3><p>This function is responsible for interacting with the player. It:</p><ul><li>Displays available choices in a menu format</li><li>Accepts numeric input from the user</li><li>Converts the numeric input into a valid game choice (Rock, Paper, or Scissors)</li><li>Handles invalid inputs using <strong>recursion</strong>, ensuring the game continues smoothly</li></ul><p>This approach prevents the program from crashing due to incorrect user input.</p><h3>2️⃣ get_computer_choice()</h3><p>This function:</p><ul><li>Stores all possible moves in a list</li><li>Uses random.choice() to select one move</li></ul><p>Because of randomness, every round feels unpredictable and fair.</p><h3>3️⃣ play_game()</h3><p>This is the <strong>core function</strong> of the project. It:</p><ul><li>Displays the game banner</li><li>Takes the number of rounds as input</li><li>Initializes score variables for player, computer, and ties</li><li>Runs the game loop for the specified number of rounds</li><li>Applies Rock Paper Scissors rules using conditional statements</li><li>Displays a live scorecard after each round</li><li>Shows the final result and declares the winner</li></ul><p>A time.sleep(2) delay is added to simulate real-time gameplay and improve readability of outputs.</p><h3>📊 Scorecard and Final Results</h3><p>After every round, the scorecard displays:</p><ul><li>Player Score</li><li>Computer Score</li><li>Tie Score</li></ul><p>Once all rounds are completed, the program compares the final scores and declares:</p><ul><li>Player as winner</li><li>Computer as winner</li><li>Or a tie game</li></ul><p>This gives a clear and satisfying conclusion to the game.</p><h3>🚀 Why This Project Is Useful</h3><p>This project helps learners:</p><ul><li>Understand <strong>real-world application of Python basics</strong></li><li>Improve <strong>logical and analytical thinking</strong></li><li>Learn how to structure programs using functions</li><li>Build confidence in creating interactive console-based applications</li></ul><p>It can be further enhanced by:</p><ul><li>Adding exception handling (try-except)</li><li>Creating a graphical user interface (GUI)</li><li>Saving scores to a file or database</li><li>Converting it into a web-based game</li></ul><h3>✅ Conclusion</h3><p>The Rock Paper Scissors game is a simple yet powerful project to strengthen Python fundamentals. By combining functions, loops, conditional logic, and randomness, this project demonstrates how basic concepts come together to create a complete interactive application.</p><p>If you are learning Python, projects like this are a great way to move from theory to practice.</p><p><strong>Happy Coding! 🐍🎮</strong></p><p>🖥️ <strong>Code Output (5 Rounds Execution)</strong></p><pre>-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-<br>|    ROCK PAPER SCISSORS      |<br>-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-<br>How many rounds do you want to play? 5<br><br>Game Starting.........<br><br>-------------------------------<br>         Round &gt;  1<br>------------------------------<br>      Pick your Choice<br>------------------------------<br>Your Choices are:<br>1. Rock<br>2. Paper<br>3. Scissors<br>------------------------------<br>Enter your choice: 1<br>------------------------------<br>Player choice:  Rock<br>Computer choice:  Scissors<br>Yeah, You won<br>------------------------------------<br>Player Score -&gt; 1<br>Computer Score -&gt; 0<br>Tie Score -&gt; 0<br>------------------------------------<br><br>-------------------------------<br>         Round &gt;  2<br>------------------------------<br>      Pick your Choice<br>------------------------------<br>Your Choices are:<br>1. Rock<br>2. Paper<br>3. Scissors<br>------------------------------<br>Enter your choice: 4<br>------------------------------<br>Invalid choice! Enter Again<br><br>------------------------------<br>      Pick your Choice<br>------------------------------<br>Your Choices are:<br>1. Rock<br>2. Paper<br>3. Scissors<br>------------------------------<br>Enter your choice: 2<br>------------------------------<br>Player choice:  Paper<br>Computer choice:  Paper<br>Oops, It&#39;s a tie!<br>------------------------------------<br>Player Score -&gt; 1<br>Computer Score -&gt; 0<br>Tie Score -&gt; 1<br>------------------------------------<br><br>-------------------------------<br>         Round &gt;  3<br>------------------------------<br>      Pick your Choice<br>------------------------------<br>Your Choices are:<br>1. Rock<br>2. Paper<br>3. Scissors<br>------------------------------<br>Enter your choice: 3<br>------------------------------<br>Player choice:  Scissors<br>Computer choice:  Paper<br>Yeah, You won<br>------------------------------------<br>Player Score -&gt; 2<br>Computer Score -&gt; 0<br>Tie Score -&gt; 1<br>------------------------------------<br><br>-------------------------------<br>         Round &gt;  4<br>------------------------------<br>      Pick your Choice<br>------------------------------<br>Your Choices are:<br>1. Rock<br>2. Paper<br>3. Scissors<br>------------------------------<br>Enter your choice: 2<br>------------------------------<br>Player choice:  Paper<br>Computer choice:  Scissors<br>Ohh, Computer won<br>------------------------------------<br>Player Score -&gt; 2<br>Computer Score -&gt; 1<br>Tie Score -&gt; 1<br>------------------------------------<br><br>-------------------------------<br>         Round &gt;  5<br>------------------------------<br>      Pick your Choice<br>------------------------------<br>Your Choices are:<br>1. Rock<br>2. Paper<br>3. Scissors<br>------------------------------<br>Enter your choice: 1<br>------------------------------<br>Player choice:  Rock<br>Computer choice:  Rock<br>Oops, It&#39;s a tie!<br>------------------------------------<br>Player Score -&gt; 2<br>Computer Score -&gt; 1<br>Tie Score -&gt; 2<br>------------------------------------<br><br>-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-<br>|       Final Score Time      |<br>-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-<br><br>Player Score -&gt; 2<br>Computer Score -&gt; 1<br>Tie Score -&gt; 2<br>-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-<br>       Game Over<br>     You won the Game!<br>-------------------------------</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7afe69c0014a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Inside the Avocado Market: A Data-Driven Analysis of Hass Avocado Sales in the U.S.]]></title>
            <link>https://medium.com/@sakhil1991/inside-the-avocado-market-a-data-driven-analysis-of-hass-avocado-sales-in-the-u-s-3e73e091cb7b?source=rss-62c052f29643------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e73e091cb7b</guid>
            <category><![CDATA[data-visualisation]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[avocado-sales]]></category>
            <category><![CDATA[excel-pivot-tables]]></category>
            <dc:creator><![CDATA[Akhil Sharma]]></dc:creator>
            <pubDate>Thu, 07 Aug 2025 18:04:39 GMT</pubDate>
            <atom:updated>2025-08-07T18:04:39.791Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>By Akhil Sharma</strong><br><em>Data Analyst | Excel Dashboard Creator | Sales Data Explorer</em></p><h3>🏪 Introduction: Why Avocado Sales Matter</h3><p>The avocado market has grown into a significant segment within the fresh produce industry in the United States. Among the varieties available, <strong>Hass avocados</strong> dominate due to their rich flavor, long shelf life, and year-round availability.</p><p>To better understand market dynamics, I analyzed <strong>four years of retail scan data (2015–2018)</strong> published by the <a href="http://www.hassavocadoboard.com/retail/volume-and-price-data">Hass Avocado Board</a>. This report aims to explore key insights around <strong>sales volume, pricing trends, product type performance, and regional consumption</strong>.</p><h3>📈 Dashboard Highlights</h3><p>To make this massive dataset digestible and insightful, I built a visual dashboard using <strong>Excel Pivot Tables</strong> and Charts. Here’s what I uncovered:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LEWBVzQlJ2zfYwK-2pR-2g.png" /></figure><h3>📊 Key Insights from the Dashboard</h3><h3>1. 🥑 Sales Volume: Consistent Growth with Seasonal Highs</h3><p>Analyzing total volume over time reveals a <strong>steady year-on-year increase</strong> in avocado consumption, with strong sales in <strong>Q1 and Q2</strong> across all years.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*Eae1E-0CdYUkYmuv36oCIw.png" /></figure><p>These spikes align with national events (e.g., Super Bowl, Cinco de Mayo) and warmer seasons — periods typically associated with dips, spreads, and outdoor meals.</p><blockquote><strong><em>Insight</em></strong><em>: Seasonal demand is predictable, allowing for </em><strong><em>inventory optimization and timely promotions</em></strong><em>.</em></blockquote><h3>2. 💲 Price Trends: Organic vs. Conventional</h3><p>A comparison of unit prices indicates that <strong>organic avocados consistently sell at a premium</strong> (approx. 20–30% higher) than conventional ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*ZyrQkaarnAv4T6ngPP881g.png" /></figure><p>While prices fluctuate mildly over years, they remain relatively stable — with <strong>organic averaging between $1.40–$1.60</strong> and <strong>conventional between $1.00–$1.20</strong>.</p><blockquote><strong><em>Insight</em></strong><em>: This pricing gap justifies </em><strong><em>differentiated marketing strategies</em></strong><em> and </em><strong><em>margin planning</em></strong><em> across SKUs.</em></blockquote><h3>3. 📈 Forecasting Sales: 2018–2019 Trends</h3><p>When plotting historical data into forecasting models, we observe:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*J_KNU5PtEdTVQW1shJT6AA.png" /></figure><ul><li>A <strong>stable demand trajectory</strong> between 2018 and 2019</li><li>No major market contraction or saturation</li><li>Sales resilience even during price peaks</li></ul><blockquote><strong><em>Insight</em></strong><em>: Hass avocados maintain strong consumer demand, positioning them as a </em><strong><em>reliable product</em></strong><em> in the fresh produce category.</em></blockquote><h3>4. 📍 Top 7 Performing Regions by Volume</h3><p>The highest-selling regions include:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*tacyW5XzTdUN1HJUjK_P6w.png" /></figure><ol><li><strong>West</strong></li><li><strong>California</strong></li><li><strong>South Central</strong></li><li><strong>Northeast</strong></li><li><strong>Southeast</strong></li><li><strong>Great Lakes</strong></li><li><strong>Total U.S.</strong> (for national reference)</li></ol><blockquote><strong><em>Insight</em></strong><em>: These regions represent </em><strong><em>key distribution and promotion zones</em></strong><em> for producers, importers, and retailers.</em></blockquote><h3>🧾 Strategic Implications for Retailers and Analysts</h3><ul><li>🛒 <strong>Category Managers</strong> can plan avocado promotions around Q1 spikes</li><li>🚚 <strong>Supply Chain Teams</strong> can optimize cold storage and replenishment cycles in high-demand regions</li><li>💼 <strong>Sales Teams</strong> can use regional data to <strong>target high-performing zones</strong> with better trade margins</li><li>📉 <strong>Pricing Analysts</strong> can forecast margins by SKU type (organic vs conventional)</li></ul><h3>🧰 Tools Used</h3><ul><li><strong>Microsoft Excel</strong> (Pivot Tables, Charts, Forecasting, Slicers)</li><li><strong>Hass Avocado Board Data</strong></li><li>Custom dashboard featuring 4 key visuals:</li><li>Price vs Year</li><li>Volume comparison</li><li>Predictive line chart</li><li>Regional ranking chart</li></ul><h3>📚 References</h3><ul><li><a href="http://www.hassavocadoboard.com/retail/volume-and-price-data">Hass Avocado Board Retail Sales Data</a></li></ul><h3>📌 Conclusion</h3><p>The Hass avocado market in the U.S. shows <strong>sustained growth</strong>, <strong>regional concentration</strong>, and <strong>clear seasonal behavior</strong> — making it a valuable case study in retail analytics.</p><p>By translating raw data into actionable insights, stakeholders can make informed decisions on:</p><ul><li>SKU planning</li><li>Pricing strategy</li><li>Promotional timing</li><li>Regional logistics</li></ul><p>For businesses operating in fresh produce, grocery retail, or CPG analytics — avocado sales provide more than just a trend. They offer a model of <strong>data-backed demand forecasting</strong> and <strong>category intelligence</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e73e091cb7b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>