<?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 Mahesh Manekar on Medium]]></title>
        <description><![CDATA[Stories by Mahesh Manekar on Medium]]></description>
        <link>https://medium.com/@manekarms03?source=rss-7f9cacd76c24------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*uU7gK1mzgghCCSdF</url>
            <title>Stories by Mahesh Manekar on Medium</title>
            <link>https://medium.com/@manekarms03?source=rss-7f9cacd76c24------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 02:08:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@manekarms03/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[When to use BETWEEN vs IN in MySQL]]></title>
            <link>https://medium.com/@manekarms03/when-to-use-between-vs-in-in-mysql-8222b7386197?source=rss-7f9cacd76c24------2</link>
            <guid isPermaLink="false">https://medium.com/p/8222b7386197</guid>
            <dc:creator><![CDATA[Mahesh Manekar]]></dc:creator>
            <pubDate>Tue, 30 Jan 2024 17:40:10 GMT</pubDate>
            <atom:updated>2024-01-30T17:40:10.534Z</atom:updated>
            <content:encoded><![CDATA[<p>Meet Jack, a diligent data analyst at a thriving e-commerce company. His current assignment involves delving into customer purchase data to uncover trends and patterns. One crucial question driving his analysis is- <strong>Within specific price ranges, which products emerge as the most popular choices among customers?</strong></p><p>Let’s assume products table has columns like product_id, product_name, price, and category. Here&#39;s a sample:</p><pre>product_id | product_name | price |   category<br>-------------------------------------------------<br>     1     |    Laptop    |  800  | Electronics<br>     2     |  Smartphone  |  500  | Electronics<br>     3     |  Headphones  |  100  | Electronics<br>     4     |   T-shirt    |  20   | Clothing<br>     5     |   Jeans      |  50   | Clothing</pre><p>Now, the showdown- BETWEEN vs IN</p><h3><strong>Scenario 1- Identifying Products within a Specific Price Range</strong></h3><p>Jack want to find products priced between $200 and $400 (inclusive). Here’s how BETWEEN and IN come into play-</p><pre>-- Using BETWEEN<br>SELECT * FROM products WHERE price BETWEEN 200 AND 400;<br><br>-- Using IN<br>SELECT * FROM products WHERE price IN (200, 250, 300, 350, 400);</pre><p><strong>Explaination-</strong></p><p>BETWEEN is ideal for continuous ranges. It efficiently checks if a value falls within the specified minimum and maximum (inclusive).</p><p>IN is better for discrete sets of values. It explicitly lists each value to be matched.</p><h3><strong>Scenario 2- Finding Products in Multiple Price Ranges</strong></h3><p>Jack now want to include products priced between $100 and $200, as well as those above $500. Here’s the adjusted code-</p><pre>-- Using BETWEEN (modified)<br>SELECT * FROM products<br>WHERE (price BETWEEN 100 AND 200) OR price &gt; 500;<br><br>-- Using IN (not applicable)</pre><p><strong>Explanation-</strong></p><ul><li>BETWEEN can be combined with logical operators like OR to handle multiple ranges, but it becomes less readable.</li><li>IN is not suitable for this scenario as it cannot handle ranges or combine conditions effectively.</li></ul><p>Thank you for reading!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8222b7386197" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Chaos to Clarity- Streamlining MySQL Queries with CTEs]]></title>
            <link>https://medium.com/@manekarms03/from-chaos-to-clarity-streamlining-mysql-queries-with-ctes-f03e57e3c531?source=rss-7f9cacd76c24------2</link>
            <guid isPermaLink="false">https://medium.com/p/f03e57e3c531</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[common-table-expressions]]></category>
            <category><![CDATA[mysql]]></category>
            <dc:creator><![CDATA[Mahesh Manekar]]></dc:creator>
            <pubDate>Tue, 02 Jan 2024 04:17:03 GMT</pubDate>
            <atom:updated>2024-01-02T04:17:03.625Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AFeOxpmY4HjpmHlmnWBNDA.jpeg" /><figcaption><a href="https://www.freepik.com/free-ai-image/view-3d-businessman_59999137.htm#fromView=search&amp;term=intelligence+board&amp;track=ais_ai_generated&amp;regularType=ai&amp;page=1&amp;position=23&amp;uuid=60b1344c-cf86-457b-abdc-557ec946144f">Image by Freepik</a></figcaption></figure><h3><strong>What is CTE?</strong></h3><p>A Common Table Expression (CTE) is a temporary result set that can be referred to within a SELECT, INSERT, UPDATE, or DELETE statement. It provides a way to break down queries into more manageable components, making SQL code more readable and maintainable.</p><h3><strong>But Why to use CTE in MySQL?</strong></h3><ol><li><strong>Modularity and Readability-</strong> CTEs allow you to modularize your SQL code by defining temporary result sets. This modularity enhances code readability, as complex queries can be broken down into smaller, more focused components.</li><li><strong>Code Reusability-</strong> With CTEs, you can create reusable code snippets that can be referenced multiple times within a query and this avoids redundancy.</li><li><strong>Simplifying Recursive Queries-</strong> CTEs are particularly useful for handling recursive queries, where a query references itself. This simplifies the code structure and makes it easier to comprehend.</li></ol><h3><strong>Types of CTE’s</strong></h3><p><strong><em>Non-Recursive CTEs</em></strong>-</p><p>This CTEs are used when the CTE does not refer to itself within its definition. They are suitable for scenarios where a temporary result set needs to be defined without involving recursion. Let’s look at the example-</p><p>Consider a scenario where you have a table named orders with columns order_id, customer_id, order_date, and total_amount. You want to find the average order amount for each customer.</p><pre>WITH customer_avg_orders AS (<br>    SELECT<br>        customer_id,<br>        AVG(total_amount) AS average_order_amount<br>    FROM<br>        orders<br>    GROUP BY<br>        customer_id<br>)<br><br>SELECT * FROM customer_avg_orders;</pre><p>In this example, the non-recursive CTE named customer_avg_orders calculates the average order amount for each customer. The main query then selects and displays the results from this CTE. This approach simplifies the main query and makes it more readable.</p><p><strong><em>Recursive CTEs-</em></strong></p><p>Recursive CTEs allow the CTE to refer to itself within its own definition. They are particularly useful for scenarios involving hierarchical or tree-like data structures. Let’s look at the example-</p><p>Consider an organizational hierarchy represented by a table named employees with columns employee_id, manager_id, and employee_name. You want to retrieve the hierarchical structure of the organization.</p><pre>WITH RECURSIVE org_hierarchy AS (<br>    SELECT employee_id, manager_id, employee_name<br>    FROM employees<br>    WHERE manager_id IS NULL  -- Anchor member<br><br>    UNION ALL<br><br>    SELECT e.employee_id, e.manager_id, e.employee_name<br>    FROM employees e<br>    JOIN org_hierarchy o ON e.manager_id = o.employee_id  -- Recursive member<br>)<br><br>SELECT * FROM org_hierarchy;</pre><p>In this example, the recursive CTE named org_hierarchy starts with the anchor member, which selects employees without managers (those at the top of the hierarchy). The recursive member then joins the CTE with the employees table to traverse the hierarchy, including each employee and their respective manager. This results in a hierarchical view of the organizational structure.</p><h3><strong>Summary-</strong></h3><p>CTEs in MySQL are a valuable tool and providing a way to enhance code modularity, readability, and maintainability. By breaking down complex queries into manageable components, CTEs contribute to a more efficient and organized SQL codebase. As demonstrated through practical examples, incorporating CTEs into your MySQL queries can simplify tasks and make your code more powerful and concise.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f03e57e3c531" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Past to Future- Lead and Lag Functions Transforming Data Perspectives!]]></title>
            <link>https://medium.com/@manekarms03/the-time-travelers-of-mysql-lead-and-lag-functions-1907a4d7f8ce?source=rss-7f9cacd76c24------2</link>
            <guid isPermaLink="false">https://medium.com/p/1907a4d7f8ce</guid>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Mahesh Manekar]]></dc:creator>
            <pubDate>Sun, 31 Dec 2023 15:02:47 GMT</pubDate>
            <atom:updated>2023-12-31T15:21:43.781Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0zMyCKGPClzGdHLsKkL0dg.jpeg" /><figcaption><a href="https://www.freepik.com/free-ai-image/business-person-futuristic-business-environment_94958610.htm#fromView=search&amp;term=SQL+developer&amp;track=ais_ai_generated&amp;regularType=ai&amp;page=1&amp;position=36&amp;uuid=94de0ba4-9cc1-4dff-81de-66d82a69854d">Image by Freepik</a></figcaption></figure><blockquote>Lead and Lag functions stand out as powerful tools for navigating and extracting valuable insights from the datasets. Let’s deep dive into the magic of Lead and Lag window functions and explore their practical applications through MySQL examples.</blockquote><p><strong>Understanding Lead and Lag Functions-</strong></p><p>Lead and Lag functions operate on a set of rows related to the current row within a specified window, providing access to subsequent (Lead) or preceding (Lag) values in a result set. These functions prove invaluable when dealing with time-series data, enabling the comparison of current values with future or past values.</p><p><strong>Let’s look at the Practical Examples-</strong></p><h3><strong>Lead Function</strong></h3><p>Imagine you’re tracking the temperature over the course of a week. The Lead function can help you see what the temperature will be on the next day.</p><pre>-- Retrieve date, current temperature, and the forecast for the next day<br>SELECT<br>    date,<br>    temperature,<br>    LEAD(temperature) OVER (ORDER BY date) AS next_day_forecast<br>FROM<br>    weather_data;</pre><p>Here, the Lead function gives us a sneak peek into the future temperature based on the date order.</p><h3>Lag Function</h3><p>Now, let’s say you’re analyzing stock prices. The Lag function can help to compare today’s closing price with yesterday’s, offering insights into market trends.</p><pre>-- Display date, closing price, and the previous day&#39;s closing price<br>SELECT<br>    date,<br>    closing_price,<br>    LAG(closing_price) OVER (ORDER BY date) AS prev_day_closing<br>FROM<br>    stock_prices;</pre><p>In this example, the Lag function helps us assess how today’s closing price relates to yesterday’s, helps in understanding market trends.</p><h3>But why to use these window functions-</h3><ol><li><strong>Seamless Comparison-</strong> Lead and Lag functions simplify the process of comparing current values with future or past values, streamlining trend analysis and forecasting.</li><li><strong>Enhanced Readability-</strong> By avoiding self-joins and subqueries, these functions contribute to more readable and maintainable SQL code, improving overall query efficiency.</li><li><strong>Dynamic Window Specification-</strong> The ability to define window specifications dynamically allows analyses based on specific business requirements.</li></ol><h3>Summary</h3><p>Lead and Lag functions in MySQL are more than just technical tools, Whether you’re planning for tomorrow’s weather, navigating the stock market, or optimizing supply chains, these functions helps to uncover patterns and make informed decisions. So, the next time you dive into your data, remember the magic that Lead and Lag bring to the table, turning numbers into actionable insights.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1907a4d7f8ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Navigating Through Insights Using Aggregate and Window Functions in MySQL]]></title>
            <link>https://medium.com/@manekarms03/navigating-through-insights-using-aggregate-and-window-functions-in-mysql-cf9eb0b8c996?source=rss-7f9cacd76c24------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf9eb0b8c996</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Mahesh Manekar]]></dc:creator>
            <pubDate>Sat, 23 Dec 2023 17:31:57 GMT</pubDate>
            <atom:updated>2023-12-23T17:31:57.005Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="https://www.freepik.com/free-photo/programming-background-with-person-working-with-codes-computer_38669443.htm#query=sql&amp;position=16&amp;from_view=keyword&amp;track=sph&amp;uuid=7e61217d-1a70-4d57-945d-5033c2f21063" src="https://cdn-images-1.medium.com/max/1024/1*MDbRBe0ZXLAmlYj2VowOCg.jpeg" /><figcaption><a href="https://www.freepik.com/free-photo/programming-background-with-person-working-with-codes-computer_38669443.htm#query=sql&amp;position=16&amp;from_view=keyword&amp;track=sph&amp;uuid=7e61217d-1a70-4d57-945d-5033c2f21063">Image by Freepik</a></figcaption></figure><blockquote>MySQL stands tall as one of the most popular relational database systems. When it comes to extracting insights from the data, understanding the nuances between aggregate functions and window functions is crucial. Let’s dive into the key distinctions and explore practical examples to illuminate their unique roles.</blockquote><h3><strong>Aggregate Functions- Summarizing the Big Picture</strong></h3><p>Aggregate functions in MySQL summarize data across multiple rows, producing a single result. Common aggregate functions include SUM(), AVG(), COUNT(), MAX(), and MIN(). These functions collapse a dataset into a singular value, offering a snapshot of the overall trends or characteristics. Let’s take an practical example.</p><pre>SELECT SUM(sales_amount) AS total_sales<br>FROM sales_data;</pre><p>This query calculates the total sales by summing up the ‘sales_amount’ column in the ‘sales_data’ table.</p><h3>Window Functions- Peeking into the Details</h3><p>Window functions, on the other hand, provide a more granular approach to data analysis. They operate over a specific “window” or subset of rows within the result set, allowing you to perform calculations on rows related to the current row. Examples of window functions include ROW_NUMBER(), RANK(), and LAG(). Let’s take an practical example.</p><pre>SELECT sales_date, sales_amount,<br>SUM(sales_amount) OVER (ORDER BY sales_date) AS running_total<br>FROM sales_data;</pre><p>In this query, the window function SUM() is used to calculate the running total of sales_amount over the ordered ‘sales_date’. The result showcases a running tally, giving insights into the incremental growth of sales.</p><p><strong><em>Key Differences between two functions-</em></strong></p><ol><li><strong>Scope of Operation-</strong></li></ol><ul><li>Aggregate functions consider the entire result set.</li><li>Window functions operate within a specified window of rows.</li></ul><p>2. <strong>Result Presentation-</strong></p><ul><li>Aggregate functions produce a single value for the entire dataset.</li><li>Window functions generate results for each row, providing detailed insights.</li></ul><p>3. <strong>Usage in SELECT Clause-</strong></p><ul><li>Aggregate functions are typically used in the SELECT clause.</li><li>Window functions often accompany an OVER() clause within the SELECT statement.</li></ul><p>In Summary, MySQL aggregate functions offer a bird’s-eye view of data, window functions zoom in to reveal intricate details within specific contexts. By leveraging both types of functions, you can unlock a comprehensive understanding of your dataset.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf9eb0b8c996" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[No More Data Confusion: MySQL Ranking Made Easy! ‍♂️]]></title>
            <link>https://medium.com/@manekarms03/no-more-data-confusion-mysql-rankings-made-easy-%EF%B8%8F-81c63b82c790?source=rss-7f9cacd76c24------2</link>
            <guid isPermaLink="false">https://medium.com/p/81c63b82c790</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Mahesh Manekar]]></dc:creator>
            <pubDate>Fri, 22 Dec 2023 18:19:31 GMT</pubDate>
            <atom:updated>2023-12-22T18:21:51.188Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="&lt;a href=”https://www.freepik.com/free-ai-image/futuristic-computer-network-powers-global-communications-inside-modern-factory-generated-by-artificial-intelligence_79682847.htm#fromView=search&amp;term=database&amp;track=ais_ai_generated&amp;regularType=ai&amp;page=1&amp;position=7&amp;uuid=a8dc4a2b-b6f7-4ef0-abd5-ac4a5df9395f&quot;&gt;Image By vecstock&lt;/a&gt;" src="https://cdn-images-1.medium.com/max/1024/1*U52OGlKD8RGNUZiT2RAbfA.jpeg" /><figcaption><a href="https://www.freepik.com/free-ai-image/futuristic-computer-network-powers-global-communications-inside-modern-factory-generated-by-artificial-intelligence_79682847.htm#fromView=search&amp;term=database&amp;track=ais_ai_generated&amp;regularType=ai&amp;page=1&amp;position=7&amp;uuid=a8dc4a2b-b6f7-4ef0-abd5-ac4a5df9395f">Image by vecstock</a></figcaption></figure><p>When it comes to sorting and ranking the data, two commonly used functions are RANK() and DENSE_RANK(). Understanding when to use each is crucial for optimizing queries and obtaining accurate results. In this blog, we’ll look at RANK() and DENSE_RANK(), also practical examples to illuminate their applications.</p><blockquote>RANK() and DENSE_RANK() are window functions that assign a unique rank to each row based on specified criteria. The primary difference lies in how they handle ties situations where two or more rows share the same values.</blockquote><h3><strong><em>RANK-</em></strong></h3><p>RANK() assigns the same rank to rows with identical values and leaves gaps in the ranking sequence for tied values. This means that if two rows have the same rank, the next rank will skip the number of tied ranks.</p><pre>SELECT<br>  employee_name,<br>  salary,<br>  RANK() OVER (ORDER BY salary DESC) AS salary_rank<br>FROM<br>  employees;</pre><p>Output-</p><pre>employee_name | salary  | salary_rank<br>John          |  5000   |   1<br>Alice         |  4500   |   2<br>Bob           |  4500   |   2<br>Mary          |  4000   |   4</pre><h3><strong>DENSE_RANK -</strong></h3><p>DENSE_RANK(), on the other hand, also assigns the same rank to tied values but without leaving gaps. It ensures a continuous ranking sequence, even if multiple rows share the same values.</p><pre>SELECT<br>  employee_name,<br>  salary,<br>  DENSE_RANK() OVER (ORDER BY salary DESC) AS salary_dense_rank<br>FROM<br>  employees;</pre><p>Output-</p><pre>employee_name  | salary | salary_dense_rank<br>John           |  5000  |         1<br>Alice          |  4500  |         2<br>Bob            |  4500  |         2<br>Mary           |  4000  |         3</pre><p>Now, Let’s explore practical applications of RANK() and DENSE_RANK() in different industries.</p><ol><li><strong><em>Retail Industry- Sales Performance Ranking</em></strong></li></ol><p><strong>Use Case-</strong> In a retail setting, businesses often want to rank their products or sales representatives based on performance.</p><p><strong>Practical Application-</strong> Utilize RANK() to identify the top-selling products or DENSE_RANK() to acknowledge tied ranks without gaps. This allows businesses to highlight high-performing items or sales representatives for recognition or incentive programs.</p><pre>SELECT<br>  product_name,<br>  sales,<br>  RANK() OVER (ORDER BY sales DESC) AS sales_rank<br>FROM<br>  product_sales;</pre><p>2. <strong><em>Healthcare Industry: Patient Satisfaction</em></strong></p><p><strong>Use Case-</strong> Hospitals may want to assess and rank patient satisfaction scores for quality improvement initiatives.</p><p><strong>Practical Application-</strong> Use RANK() to identify the relative position of hospitals based on patient satisfaction scores. Recognize ties using this function to address similar performance levels effectively.</p><pre>SELECT<br>  hospital_name,<br>  patient_satisfaction,<br>  RANK() OVER (ORDER BY patient_satisfaction DESC) AS satisfaction_rank<br>FROM<br>  hospital_performance;</pre><p>3. <strong><em>Finance Industry- Credit Scoring</em></strong></p><p><strong>Use Case-</strong> Financial institutions frequently rank customers based on credit scores for loan approval processes.</p><p><strong>Practical Application-</strong> Using DENSE_RANK() to assign continuous ranks to customers with similar credit scores. This ensures a fair and seamless evaluation of creditworthiness.</p><pre>SELECT<br>  customer_name,<br>  credit_score,<br>  DENSE_RANK() OVER (ORDER BY credit_score DESC) AS credit_rank<br>FROM<br>  customer_credit_scores;</pre><p>In summary, RANK() and DENSE_RANK() are specifically designed for ranking rows based on certain criteria, considering ties and offering flexibility in handling them. They are particularly useful in scenarios where you need to identify the relative position of each row in a sorted result set. Other functions, such as ROW_NUMBER(), NTILE(), LEAD(), and LAG(), serve different purposes and are chosen based on the specific analytical requirements of your query.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81c63b82c790" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Rows to Groups- SQL’s WHERE and HAVING Unveiled ️‍♂️✨]]></title>
            <link>https://medium.com/@manekarms03/from-rows-to-groups-sqls-where-and-having-unveiled-%EF%B8%8F-%EF%B8%8F-7253459bb976?source=rss-7f9cacd76c24------2</link>
            <guid isPermaLink="false">https://medium.com/p/7253459bb976</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Mahesh Manekar]]></dc:creator>
            <pubDate>Thu, 21 Dec 2023 15:09:35 GMT</pubDate>
            <atom:updated>2023-12-21T15:09:35.270Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>When it comes to extracting data from a database using SQL, the WHERE and HAVING clauses play crucial roles, but they serve distinct purposes. Understanding when to use each is essential for efficient and accurate queries. In this blog post, we’ll look into the nuances of WHERE and HAVING clauses, accompanied by practical examples to illustrate their applications.</blockquote><h3>WHERE Clause</h3><p>The WHERE clause is used in the SQL SELECT statement to filter rows based on specific conditions. It is used primarily with aggregate functions or simple column comparisons. Let’s look at an example.</p><pre>-- Retrieve employees with a salary greater than 50000<br>SELECT * FROM employees<br>WHERE salary &gt; 50000;</pre><p>In this example, the WHERE clause filters the rows from the <strong>employees</strong> table where the <strong>salary</strong> column is greater than 50000.</p><h3>HAVING Clause</h3><p>On the other hand, the HAVING clause is used to filter the results of aggregate functions applied to grouped data. It comes into play when working with GROUP BY statements. Let’s look at an example.</p><pre>-- Retrieve departments with an average salary greater than 60000<br>SELECT department, AVG(salary) as avg_salary<br>FROM employees<br>GROUP BY department<br>HAVING AVG(salary) &gt; 60000;</pre><p>In this case, the HAVING clause filters the groups created by the GROUP BY statement, returning only those with an average salary greater than 60000.</p><h3>When to Use WHERE vs HAVING</h3><p>Use WHERE for Row-Level Filtering-</p><ul><li>When filtering individual rows based on specific conditions.</li><li>se it with simple column comparisons or logical operators.</li></ul><p>Use HAVING for Group-Level Filtering-</p><ul><li>When filtering results based on aggregate functions and GROUP BY.</li><li>Apply HAVING after GROUP BY to filter grouped data.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7253459bb976" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unveiling the Mystery- Update Vs Alter in SQL]]></title>
            <link>https://medium.com/@manekarms03/unveiling-the-mystery-update-vs-alter-in-sql-cf86d7f8c271?source=rss-7f9cacd76c24------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf86d7f8c271</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Mahesh Manekar]]></dc:creator>
            <pubDate>Wed, 20 Dec 2023 14:23:19 GMT</pubDate>
            <atom:updated>2023-12-20T14:23:19.013Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cIpA0qxg2pTcffi_" /><figcaption>Photo by <a href="https://unsplash.com/@ikukevk?utm_source=medium&amp;utm_medium=referral">Kevin Ku</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Understanding the SQL commands is crucial for database management. Update and Alter are two popular buzzwords might seem interchangeable at first glance, but a closer inspection reveals distinct purposes for each.</p><p>Let’s look at the key differences and explore the practical examples to solidify our understanding.</p><h3><strong>Update- It Enhances the Existing Data</strong></h3><blockquote>Update command is used to change the data that already exists in a database. Updating the values of particular columns in one or more rows in accordance with a specified condition. Consider the following example.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*9duoHUieiQd8AQAGHRNZ_g.png" /></figure><p><strong><em>UPDATE products</em></strong>- Specifies the table named products that you want to update.</p><p><strong><em>SET stock_quantity = stock_quantity + 50</em></strong>- Increases the stock_quantity column by 50 for the rows that meet the specified condition.</p><p><strong><em>WHERE stock_quantity &lt; 100;</em></strong> This condition ensures that the update is applied only to rows where the current stock quantity is less than 100.</p><h3><strong>Alter- Modifying Table Structure</strong></h3><blockquote>On the other hand, the Alter statement focuses on altering the structure of a table, not its data. It allows you to add, modify, or drop columns and constraints within an existing table. Consider the following example.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*K7Zyp3z_FeSqfcT7L0hW3Q.png" /></figure><p><strong><em>ALTER TABLE employees —</em></strong> This part of the statement specifies that you want to make changes to the employees table.</p><p><strong><em>ADD COLUMN department VARCHAR(50);</em></strong> — This part adds a new column named department to the employees table. The data type of the column is VARCHAR(50), indicating that it can store variable-length character strings with a maximum length of 50 characters.</p><h3>In a Nutshell</h3><p><strong>Update</strong> modifies existing records based on specified conditions.</p><p><strong>Alter</strong> modifies the structure of a table by adding, modifying, or dropping columns.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf86d7f8c271" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Short Story Series on Statistics (Mean, Median and Mode)]]></title>
            <link>https://medium.com/@manekarms03/short-story-series-on-statistics-c109ec4088df?source=rss-7f9cacd76c24------2</link>
            <guid isPermaLink="false">https://medium.com/p/c109ec4088df</guid>
            <category><![CDATA[mean]]></category>
            <category><![CDATA[median]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[Mahesh Manekar]]></dc:creator>
            <pubDate>Fri, 21 Jul 2023 14:25:19 GMT</pubDate>
            <atom:updated>2023-07-27T16:49:49.040Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5irYL-I9hQbebVXo" /><figcaption>Photo by <a href="https://unsplash.com/@markuswinkler?utm_source=medium&amp;utm_medium=referral">Markus Winkler</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this short story series, we will explore the concepts of Mean, Median, and Mode in statistics and understand their significance.</p><p>Mean, Median, and Mode are all measures of central tendency, representing the average value of a dataset. However, their roles change depending on the specific conditions for which they are applied.</p><p>Let’s start with the Mean, denoted by the symbol μ. In school, we are familiar with the concept of average, which is the sum of all the entries divided by the number of entries. In statistics, we call this the Mean, and it helps us find the average value of a dataset. For example, to determine the average age of a group of people:</p><p>Age- 20, 19, 21, 18, 17, 21</p><p><strong>Mean = (20 + 19 + 21 + 18 + 17 + 21) / 6 = 19.33</strong></p><p>The average age is calculated to be 19.33.</p><p>However, the Mean has a limitation, as it tends to be influenced by outliers in the dataset. To illustrate this, let’s consider the same age example with an outlier:</p><p>Age- 20, 19, 21, 18, 35, 40</p><p><strong>Mean = (20 + 19 + 21 + 18 + 35 + 40) / 6 = 25.5</strong></p><p>In this case, the Mean value shifted towards the outlier, giving an average age of 25.5, which is not representative of the majority of the data.</p><p>To overcome this issue, the Median comes into play. The Median is the middle value when all the data points are arranged in ascending order. Let’s use the same age example:</p><p>Age — 20, 19, 21, 18, 35, 40</p><p>Arranging in ascending order — 18, 19, 20, 21, 35, 40</p><p><strong>Median = (20 + 21) / 2 = 20.5</strong></p><p>The Median effectively handles the outliers and provides a more accurate representation of the central tendency. In this case, the Median age is 20.5.</p><p>Now, let’s explore the Mode, which is the value that appears with the highest frequency in the dataset. It is the only average that works well with categorical data. For instance:</p><p>Age- 20, 19, 21, 18, 17, 21</p><p><strong>Mode = 21</strong></p><p>In this example, 21 appears most frequently, making it the Mode.</p><p>In summary, Mean, Median, and Mode are essential statistical measures that help us understand the central tendencies of a dataset, and each has its unique strengths and applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c109ec4088df" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>