<?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 Jonathan Mukundu on Medium]]></title>
        <description><![CDATA[Stories by Jonathan Mukundu on Medium]]></description>
        <link>https://medium.com/@jonamukundu?source=rss-8cc831762762------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Ag88RjeP4zGOhy8m.</url>
            <title>Stories by Jonathan Mukundu on Medium</title>
            <link>https://medium.com/@jonamukundu?source=rss-8cc831762762------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 06:47:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jonamukundu/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[WHAT NEXT AFTER BASIC SQL]]></title>
            <link>https://medium.com/@jonamukundu/what-next-after-basic-sql-183b8ad125c8?source=rss-8cc831762762------2</link>
            <guid isPermaLink="false">https://medium.com/p/183b8ad125c8</guid>
            <dc:creator><![CDATA[Jonathan Mukundu]]></dc:creator>
            <pubDate>Sat, 14 Mar 2026 10:53:16 GMT</pubDate>
            <atom:updated>2026-03-14T10:53:16.030Z</atom:updated>
            <content:encoded><![CDATA[<p>Are you on a journey to learn data analytics using SQL? OK. <br>STEP1: Install a good database environment like SQL SERVER plus DUCKDB or POSTGRESQL<br>STEP2:Get the basics out of the way i.e SELECT FROM WHERE GROUP BY HAVING ORDER BY LIMIT JOINS FUNCTIONS DATE/TIME<br>STEP3: VALUE clause , CTE , WINDOW FUNCTIONS [RANKING , AGGREGATE, LAG, LEAD, FIRST_VALUE,LAST_VALUE]<br>TIP : USE AI tools like CHATGPT etc to create some real life database tables and data in two segments: 1. small datasets for learning and or / non physical datasets using VALUES clause 2.Real life generated big datasets of anything between 10000 to 100000 rows that are related to your DOMAIN<br>CHEERS!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=183b8ad125c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Analysts]]></title>
            <link>https://medium.com/@jonamukundu/data-analysts-e0f537c6428c?source=rss-8cc831762762------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0f537c6428c</guid>
            <dc:creator><![CDATA[Jonathan Mukundu]]></dc:creator>
            <pubDate>Sat, 14 Mar 2026 02:13:21 GMT</pubDate>
            <atom:updated>2026-03-14T02:13:21.681Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*Mq2XyELuMkFQAZ-DZUGxnw.png" /></figure><p>In my experience, strong data analysts combine <strong>domain knowledge</strong> with <strong>solid data fundamentals</strong>.</p><p>Many domain specialists understand their field very well, but fewer invest time in building the core analytical skills that make data truly useful.</p><p>A practical toolkit often includes:</p><p>• Excel / Spreadsheets (still powerful and sometimes sufficient)<br>• BI tools for dashboards and reporting<br>• SQL for working with real databases</p><p>Bonus skills:</p><p>• Python for automation and data workflows<br>• Productive use of AI tools like ChatGPT</p><p><strong>Learning tip:</strong><br>Don’t try to read a SQL book cover-to-cover before doing anything practical. It can become discouraging.</p><p>Apply the <strong>80/20 rule</strong> instead: learn the small set of concepts you will use most often and build from there.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0f537c6428c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Skills as a Universal Professional Competency]]></title>
            <link>https://medium.com/@jonamukundu/data-skills-as-a-universal-professional-competency-5776f2510d8b?source=rss-8cc831762762------2</link>
            <guid isPermaLink="false">https://medium.com/p/5776f2510d8b</guid>
            <dc:creator><![CDATA[Jonathan Mukundu]]></dc:creator>
            <pubDate>Sun, 11 Jan 2026 20:51:37 GMT</pubDate>
            <atom:updated>2026-01-11T20:51:37.625Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why Formal Credentials Are Often Secondary to Practical Capability</h3><h3>Introduction</h3><p>In contemporary discourse, “data skills” are frequently portrayed as the domain of specialized professionals — data analysts, data scientists, or data engineers — often assumed to require formal degrees, certifications, or advanced technical training. This framing, while convenient, is increasingly misaligned with reality.</p><p>In practice, <strong>data skills are not confined to a profession; they are embedded in almost every career</strong>, exercised daily in both formal and informal ways. The distinction that matters is not <em>whether</em> data skills are used, but <em>how consciously, effectively, and responsibly</em> they are applied.</p><h3>Data Skills Are Not New — Only Formalized</h3><p>Long before spreadsheets, databases, or dashboards existed, professionals made decisions based on:</p><ul><li>Counts</li><li>Comparisons</li><li>Trends over time</li><li>Proportions and rates</li><li>Exceptions and anomalies</li></ul><p>Teachers tracked student performance. Traders assessed supply and demand. Managers evaluated productivity. Health workers monitored outcomes. These are all <strong>data activities</strong>, even when no formal tools or labels were involved.</p><p>Modern tools have not invented data skills; they have <strong>formalized and scaled what people were already doing</strong>.</p><h3>Every Career Uses Data — Explicitly or Implicitly</h3><p>Across sectors, professionals routinely engage in data work:</p><ul><li>Managers interpret reports to allocate resources</li><li>Health professionals assess indicators to guide interventions</li><li>Accountants reconcile figures and detect inconsistencies</li><li>Journalists analyze trends and verify claims</li><li>Policy makers rely on summaries and projections</li><li>Engineers monitor performance metrics</li><li>Sales teams evaluate conversion rates and forecasts</li></ul><p>In many cases, this data work is:</p><ul><li>Unnamed</li><li>Undocumented</li><li>Uncertified</li><li>Learned informally</li></ul><p>Yet it directly influences decisions, outcomes, and accountability.</p><h3>The Myth of Credential-Centric Data Competence</h3><p>Formal degrees and certifications are often treated as proxies for data capability. While they can be useful signals, they are <strong>poor predictors of real-world effectiveness</strong> on their own.</p><p>Credentials typically assess:</p><ul><li>Tool familiarity</li><li>Terminology recognition</li><li>Controlled problem-solving</li></ul><p>They rarely assess:</p><ul><li>Judgment under ambiguity</li><li>Data quality trade-offs</li><li>Contextual interpretation</li><li>Stakeholder communication</li><li>Responsibility for consequences</li></ul><p>As a result, it is common to find professionals with strong credentials who struggle in applied settings, and others with minimal formal training who demonstrate exceptional data competence through experience.</p><h3>What Practical Data Skill Actually Consists Of</h3><p>Across roles and industries, effective data skill tends to rest on a common foundation:</p><ol><li><strong>Data Literacy</strong><br> Understanding what the data represents, where it comes from, and its limitations.</li><li><strong>Logical Reasoning</strong><br> Applying basic arithmetic, comparisons, and conditional thinking correctly and consistently.</li><li><strong>Context Awareness</strong><br> Interpreting numbers within operational, organizational, or domain-specific realities.</li><li><strong>Model Thinking</strong><br> Understanding how data is structured, aggregated, filtered, or summarized — and how those choices affect results.</li><li><strong>Communication</strong><br> Explaining insights clearly, responsibly, and defensibly to non-technical audiences.</li><li><strong>Judgment and Ethics</strong><br> Knowing when data is sufficient, when it is misleading, and when not to act on it..</li><li>These competencies are <strong>largely independent of formal academic depth</strong> and are developed primarily through application and responsibility.</li></ol><h3>Tools Do Not Replace Thinking — They Amplify It</h3><p>Modern analytics tools lower technical barriers, but they do not remove the need for reasoning. On the contrary, they amplify both:</p><ul><li>Good thinking (by scaling clarity and insight)</li><li>Poor thinking (by scaling error and misinterpretation)</li></ul><p>The limiting factor in most data-driven environments is not tool capability, but:</p><ul><li>Misunderstood metrics</li><li>Poor assumptions</li><li>Inconsistent definitions</li><li>Unexamined bias</li><li>Overconfidence in outputs</li></ul><p>These are human issues, not technical ones.</p><h3>Experience as the Primary Teacher</h3><p>Most meaningful data competence is acquired through:</p><ul><li>Repeated exposure to real data</li><li>Encountering and correcting errors</li><li>Responding to scrutiny and questions</li><li>Reconciling conflicting indicators</li><li>Making decisions that carry consequences</li></ul><p>This experiential learning produces intuition and judgment that cannot be easily standardized or examined, yet it is precisely what organizations rely on most.</p><h3>Reframing Data Skills in Career Development</h3><p>Rather than treating data skills as a specialized career track, it is more accurate to view them as:</p><ul><li>A <strong>core professional literacy</strong></li><li>Comparable to writing, numeracy, or communication</li><li>Applicable across disciplines and seniority levels</li></ul><p>Specialization still matters in advanced technical roles, but for the majority of professionals, <strong>data competence is about informed use, not technical mastery</strong>.</p><h3>Conclusion</h3><p>Data skills are not the exclusive property of data professionals, nor are they primarily conferred by degrees or certifications. They are <strong>a universal professional capability</strong>, exercised daily across roles, often without formal recognition.</p><p>What distinguishes effective practitioners is not their credentials, but their ability to:</p><ul><li>Think clearly with data</li><li>Understand context</li><li>Communicate responsibly</li><li>Apply judgment under uncertainty</li></ul><p>As organizations increasingly describe themselves as “data-driven,” the real challenge is not producing more certified specialists, but <strong>raising the baseline of data competence across all careers</strong>.</p><p>In that sense, data skills are not a career path.<br> They are part of being professionally competent in the modern world.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5776f2510d8b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[VLookup vs XLookup]]></title>
            <link>https://medium.com/@jonamukundu/vlookup-vs-xlookup-955d775d1844?source=rss-8cc831762762------2</link>
            <guid isPermaLink="false">https://medium.com/p/955d775d1844</guid>
            <dc:creator><![CDATA[Jonathan Mukundu]]></dc:creator>
            <pubDate>Mon, 08 Dec 2025 09:58:57 GMT</pubDate>
            <atom:updated>2025-12-19T12:40:15.419Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*hXJbyhz8SQZKUSKvPQKcEw.png" /></figure><p>Please dont tell people to forget VLookup because for some people that is all they have in their version of Excel. For those that have later versions of Excel please forget VLookup and go for Xlookup but its important to know how to use VLookup just in case you will share reports with older versions. Index /Match is good but can be tricky. For VLookup, just understand the inputs in plain english [ChatGPT can help] but for a start just set up your environment as shown in the illustration:</p><p>IMPORTANT: Before you tackle Lookups understand LOCKING TYPES</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*7AUC1y6ar7t54OKt3SKZSg.png" /></figure><p>Make sure where you are looking from has a UNIQUE ID for consistent results otherwise Excel will pick the first one it finds.. On a serious note you can Graduate to POWER QUERY and SQL if you really want to forget about LOOKUPS but they are handy within Excel!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=955d775d1844" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A SQL Window function script that shows important good practices]]></title>
            <link>https://medium.com/@jonamukundu/a-sql-window-function-script-that-shows-important-good-practices-c79eb671d74a?source=rss-8cc831762762------2</link>
            <guid isPermaLink="false">https://medium.com/p/c79eb671d74a</guid>
            <dc:creator><![CDATA[Jonathan Mukundu]]></dc:creator>
            <pubDate>Thu, 20 Nov 2025 09:06:55 GMT</pubDate>
            <atom:updated>2025-11-20T09:06:55.430Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Me3cgNiGzl8r9IlB53WQgA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c79eb671d74a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[QUICK RECAP OF WINDOW FUNCTIONS]]></title>
            <link>https://medium.com/@jonamukundu/quick-recap-of-window-functions-d37abc24b4f0?source=rss-8cc831762762------2</link>
            <guid isPermaLink="false">https://medium.com/p/d37abc24b4f0</guid>
            <dc:creator><![CDATA[Jonathan Mukundu]]></dc:creator>
            <pubDate>Fri, 31 Oct 2025 02:44:50 GMT</pubDate>
            <atom:updated>2025-10-31T02:44:50.254Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ani_YSXXcYI9gZOSTgdb0A.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d37abc24b4f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jonathan Mukundu — Philosophy of Data Work]]></title>
            <link>https://medium.com/@jonamukundu/jonathan-mukundu-philosophy-of-data-work-94b0b40db4bc?source=rss-8cc831762762------2</link>
            <guid isPermaLink="false">https://medium.com/p/94b0b40db4bc</guid>
            <dc:creator><![CDATA[Jonathan Mukundu]]></dc:creator>
            <pubDate>Wed, 24 Sep 2025 02:39:24 GMT</pubDate>
            <atom:updated>2025-09-24T02:39:24.679Z</atom:updated>
            <content:encoded><![CDATA[<h3>Jonathan Mukundu — Philosophy of Data Work</h3><p>In today’s data-driven world, tools evolve quickly — but the fundamentals remain constant. My approach to data work is rooted in simplicity, pragmatism, and teamwork.</p><p>Excel is still king.</p><p>For speed, beauty, and simplicity, Excel remains unmatched. It handles 80–90% of daily reporting needs, from pivot tables to charts, and provides the transparency non-technical teams require. It is the fastest way to communicate data clearly.</p><p>Python and R are for scale and automation.</p><p>When datasets grow beyond Excel’s limits, or when automation and advanced analytics are needed, I turn to programming. Python and R shine in cleaning messy data, building reproducible workflows, connecting to databases/APIs, and producing flexible visuals. They are powerful allies — but only after the basics are mastered.</p><p>The real foundation is programming literacy.</p><h3>No matter the language, the same building blocks matter:</h3><h3>- Variables and data types</h3><h3>- Conditionals and loops</h3><h3>- Functions (the heartbeat of code)</h3><h3>- File management and error handling</h3><h3>- Basic understanding of OOP</h3><p>These principles make it possible to learn any language — whether Python, R, SQL, or even VBA and JavaScript.</p><p>Functions and teamwork are key.</p><p>Functions teach us how to structure logic. Teamwork ensures we don’t try to master everything alone. Just as few people can set up DHIS2 from scratch or optimize complex SQL schemas, no single person is an expert in all areas. Data excellence comes from combining strengths.</p><p>AI is the new collaborator.</p><p>Artificial intelligence accelerates coding, reporting, and charting. But AI cannot replace human judgment in data quality and validation. My role is to blend technical basics, practical tools, and AI support into solutions that actually work.</p><p>Bottom line: My philosophy is to use the right tool at the right time — Excel for clarity, SQL for structure, Python/R for automation, and AI for speed — always grounded in fundamentals and teamwork.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94b0b40db4bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Managing Duplicate Data in T-SQL: A Step-by-Step Guide]]></title>
            <link>https://medium.com/@jonamukundu/managing-duplicate-data-in-t-sql-a-step-by-step-guide-09319ea5c30f?source=rss-8cc831762762------2</link>
            <guid isPermaLink="false">https://medium.com/p/09319ea5c30f</guid>
            <dc:creator><![CDATA[Jonathan Mukundu]]></dc:creator>
            <pubDate>Wed, 20 Nov 2024 17:58:25 GMT</pubDate>
            <atom:updated>2024-11-20T17:58:25.812Z</atom:updated>
            <content:encoded><![CDATA[<p>Data management often involves ensuring that datasets meet specific integrity constraints. One common challenge is identifying and resolving duplicate records, which can violate unique constraints and impact data accuracy. In this article, I’ll demonstrate how to use Table Value Constructors (TVCs) in T-SQL to simulate data entry, identify duplicates, and clean the dataset effectively.</p><h3>Why This Matters</h3><p>Duplicate data can lead to inaccurate analysis and reporting, which may compromise business decisions. Understanding how to detect and resolve such issues is a critical skill for anyone working with databases.</p><h3>Step 1: Simulating Data with a TVC</h3><p>A <strong>Table Value Constructor (TVC)</strong> allows us to create and work with in-memory data. Below is an example dataset with a duplicate record that violates the unique constraint based on the combination of TIME, LOCATION, INDICATOR, GENDER, and AGE_GROUP.</p><p>WITH RawData AS (<br> SELECT *<br> FROM (VALUES<br> (1, ‘2024–01–01 08:00:00’, ‘Location1’, ‘Positive’, ‘Male’, ‘18–25’, 10),<br> (2, ‘2024–01–01 09:00:00’, ‘Location2’, ‘Negative’, ‘Female’, ‘26–35’, 15),<br> (3, ‘2024–01–01 10:00:00’, ‘Location3’, ‘Positive’, ‘Male’, ‘36–45’, 20),<br> (4, ‘2024–01–01 11:00:00’, ‘Location4’, ‘Negative’, ‘Female’, ‘46–55’, 25),<br> (5, ‘2024–01–01 12:00:00’, ‘Location5’, ‘Positive’, ‘Male’, ‘56+’, 30),<br> (6, ‘2024–01–01 12:00:00’, ‘Location5’, ‘Positive’, ‘Male’, ‘56+’, 50) — Duplicate record<br> ) AS TVC(ID, TIME, LOCATION, INDICATOR, GENDER, AGE_GROUP, TOTAL)<br>)</p><h3>Step 2: Identifying Duplicates</h3><p>To pinpoint duplicate records, use the COUNT(*) function in combination with a GROUP BY clause. The HAVING clause helps filter out rows where duplicate counts exceed one.</p><p>WITH DuplicateCounts AS (<br> SELECT <br> TIME,<br> LOCATION,<br> INDICATOR,<br> GENDER,<br> AGE_GROUP,<br> COUNT(*) AS Rc<br> FROM RawData<br> GROUP BY <br> TIME,<br> LOCATION,<br> INDICATOR,<br> GENDER,<br> AGE_GROUP<br> HAVING COUNT(*) &gt; 1<br>)<br>SELECT * <br>FROM DuplicateCounts;</p><p><strong>Output</strong>: This query returns the duplicate rows and the number of occurrences for each combination.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3gZt4pgbR2W8j3iAuV2I1A.png" /></figure><h3>Step 3: Cleaning the Dataset</h3><p>To remove duplicates, we use the ROW_NUMBER() function, which assigns a unique rank to each row within a duplicate group. By selecting rows where ROW_NUMBER() = 1, we retain only the first occurrence of each duplicate group.</p><p>WITH CleanedData AS (<br> SELECT *<br> FROM (<br> SELECT <br> ID, TIME, LOCATION, INDICATOR, GENDER, AGE_GROUP, TOTAL,<br> ROW_NUMBER() OVER (<br> PARTITION BY TIME, LOCATION, INDICATOR, GENDER, AGE_GROUP<br> ORDER BY ID) AS RN<br> FROM RawData<br> ) AS SubQuery<br> WHERE RN = 1<br>)<br>SELECT * <br>FROM CleanedData;</p><p>WITH CleanedData AS (<br> SELECT *<br> FROM (<br> SELECT <br> ID, TIME, LOCATION, INDICATOR, GENDER, AGE_GROUP, TOTAL,<br> ROW_NUMBER() OVER (<br> PARTITION BY TIME, LOCATION, INDICATOR, GENDER, AGE_GROUP<br> ORDER BY ID) AS RN<br> FROM RawData<br> ) AS SubQuery<br> WHERE RN = 1<br>)<br>SELECT * <br>FROM CleanedData;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*wmXzQyKIxulEPNSccQKKKA.png" /></figure><h3>Key Concepts</h3><ol><li><strong>Table Value Constructor (TVC)</strong>: Useful for testing and debugging without creating physical tables.</li><li><strong>Duplicate Detection</strong>: Leverages COUNT(*) and HAVING to identify violations.</li><li><strong>Duplicate Removal</strong>: Uses ROW_NUMBER() to isolate and retain only the required rows.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W_VdW48wWHHWVOL8RaURpw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=09319ea5c30f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DIFFERENT WAYS OF DOING SQL]]></title>
            <link>https://medium.com/@jonamukundu/different-ways-of-doing-sql-9fc86f125180?source=rss-8cc831762762------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fc86f125180</guid>
            <dc:creator><![CDATA[Jonathan Mukundu]]></dc:creator>
            <pubDate>Sat, 12 Oct 2024 16:20:30 GMT</pubDate>
            <atom:updated>2024-10-14T22:07:01.112Z</atom:updated>
            <content:encoded><![CDATA[<p>DIFFERENT WAYS OF DOING SQL</p><p>Here is a simple table , table t</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D4vYG9jMkV6JnX4v3s9JkQ.png" /></figure><p>Requirement: You have a single column x. You need to produce Total , Running Total and Moving Total along side column x as show in the table above</p><p>Basically:</p><ol><li><strong>Column </strong><strong>x</strong>: This is the original column [1, 2, 3, 4, 5].</li><li><strong>Column </strong><strong>Total</strong>: Shows the total sum of all values in x, which is 15.</li><li><strong>Column </strong><strong>Running Total</strong>: A cumulative sum of values up to the current row:</li></ol><ul><li>For row 1: 1</li><li>For row 2: 1 + 2 = 3</li><li>For row 3: 1 + 2 + 3 = 6</li><li>For row 4: 1 + 2 + 3 + 4 = 10</li><li>For row 5: 1 + 2 + 3 + 4 + 5 = 15</li></ul><ol><li><strong>Column </strong><strong>Moving Total</strong>: Uses the formula (previous row + current row + next row) with adjustments for boundary conditions:</li></ol><ul><li>Row 1: 0 + 1 + 2 = 3</li><li>Row 2: 1 + 2 + 3 = 6</li><li>Row 3: 2 + 3 + 4 = 9</li><li>Row 4: 3 + 4 + 5 = 12</li><li>Row 5: 4 + 5 + 0 = 9</li></ul><p>SQL Solution:</p><p>SELECT <br> x,<br> SUM(x) OVER () AS Total,<br> SUM(x) OVER (ORDER BY x) AS Running_Total,<br> COALESCE(LAG(x) OVER (ORDER BY x), 0) + x + COALESCE(LEAD(x) OVER (ORDER BY x), 0) AS Moving_Total<br>FROM <br> t2 ORDER BY x;</p><p>Ok i will focus on Moving_Total. How else can i generate a similar result?</p><p>SELECT <br> x,<br> SUM(x) OVER () AS Total,<br> SUM(x) OVER (ORDER BY x) AS Running_Total,<br>SUM(x) OVER (ORDER BY x ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS Moving_Total</p><p>FROM t2 ORDER BY x;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*ZyWlBgDB_X2Ymw9-lcs7-A.png" /></figure><p>The second query seems more redable but the result is the same!!</p><p>But wait a minute!!!</p><p>Sometimes readability is cardinal</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FJkoETzIWXxmoYONsgSL4A.png" /></figure><p>Both approaches will give the same results, but the second query is often preferred when readability and clarity are important. It’s also a great approach if you ever need to expand or adjust the offsets, as LAG and LEAD make it easy to modify specific row references directly…</p><p>Do you want to learn SQL… Dont waste money.. i can guide you for FREE but just for a week!! I will point you to good resource… All for FREE..</p><p>Check out my other writings and lets connect on linkedin : <a href="https://www.linkedin.com/in/jonathan-mukundu-925b067/">https://www.linkedin.com/in/jonathan-mukundu-925b067/</a></p><p>Cheers and all the BEST!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fc86f125180" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SIMPLE MACHINE LEARNING EXAMPLE]]></title>
            <link>https://medium.com/@jonamukundu/simple-machine-learning-example-6c63d8ea094f?source=rss-8cc831762762------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c63d8ea094f</guid>
            <dc:creator><![CDATA[Jonathan Mukundu]]></dc:creator>
            <pubDate>Thu, 10 Oct 2024 10:13:47 GMT</pubDate>
            <atom:updated>2024-10-10T10:13:47.191Z</atom:updated>
            <content:encoded><![CDATA[<h3>Training Data Recap</h3><p>Here’s the training dataset we used to build our model:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zfW8lCc5h2OrSfAnbiQA5A.png" /></figure><h3>New House Features</h3><p>When we predict the price for a new house, we need to specify its features. For example:</p><ul><li><strong>Size</strong>: 1700 sq ft</li><li><strong>Bedrooms</strong>: 3</li><li><strong>Location</strong>: A</li></ul><p>Using these features in the previously defined preprocess_new_data function ensures that they are converted correctly to the model&#39;s expected input format.</p><h3>Example Prediction Calculation</h3><p>Let’s say, after preprocessing, you received the following output:</p><ul><li><strong>Predicted Price</strong>: <strong>$322,222.10</strong></li></ul><p>This predicted price is calculated based on the model’s understanding of the relationships between the size, number of bedrooms, and location of houses from the training data.</p><h3>Features Corresponding to Prediction</h3><ul><li><strong>Size</strong>: 1700 sq ft</li><li><strong>Bedrooms</strong>: 3</li><li><strong>Location</strong>: A</li></ul><h3>Conclusion</h3><p>Thus, for the input features you provided (1700 sq ft, 3 bedrooms, Location A), the model predicts that the house would be priced around <strong>$322,222.10</strong>.</p><p>Python Code:</p><p>import pandas as pd<br>from sklearn.model_selection import train_test_split<br>from sklearn.linear_model import LinearRegression</p><p># Create the dataset<br>data = {<br> ‘Size’: [1500, 1800, 1200, 1600, 2000],<br> ‘Bedrooms’: [3, 4, 2, 3, 4],<br> ‘Location’: [‘A’, ‘A’, ‘B’, ‘B’, ‘C’],<br> ‘Price’: [300000, 350000, 200000, 250000, 400000] # Target variable<br>}</p><p># Convert the dictionary to a DataFrame<br>df = pd.DataFrame(data)</p><p># Separate features and target<br>X = df.drop(‘Price’, axis=1) # Features<br>y = df[‘Price’] # Target variable</p><p># One-hot encode the categorical feature (Location)<br>X_encoded = pd.get_dummies(X, columns=[‘Location’], drop_first=True)</p><p># Split the dataset into training and test sets<br>X_train, X_test, y_train, y_test = train_test_split(X_encoded, y, test_size=0.2, random_state=42)</p><p># Train the model<br>model = LinearRegression()<br>model.fit(X_train, y_train)</p><p># Function to preprocess new data<br>def preprocess_new_data(size, bedrooms, location):<br> new_data = pd.DataFrame({<br> ‘Size’: [size],<br> ‘Bedrooms’: [bedrooms],<br> ‘Location’: [location]<br> })<br> <br> # One-hot encode the new data using the same method as before<br> new_data_encoded = pd.get_dummies(new_data, columns=[‘Location’], drop_first=True)<br> <br> # Ensure that the new data has the same columns as the training data<br> missing_cols = set(X_encoded.columns) — set(new_data_encoded.columns)<br> for col in missing_cols:<br> new_data_encoded[col] = 0 # Add missing columns with 0 values<br> <br> new_data_encoded = new_data_encoded[X_encoded.columns] # Reorder columns to match training data<br> <br> return new_data_encoded</p><p># New house features for prediction (for example)<br>new_house = preprocess_new_data(size=1700, bedrooms=3, location=’A’)</p><p># Make prediction for the new house<br>predicted_price = model.predict(new_house)</p><p># Output the prediction<br>print(f”The predicted price for the new house is: ${predicted_price[0]:,.2f}”)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c63d8ea094f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>