<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Reinhard Bonnke</title>
    <description>The latest articles on DEV Community by Reinhard Bonnke (@reinhard_bonnke_3c96981a4).</description>
    <link>https://dev.to/reinhard_bonnke_3c96981a4</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3818273%2F9dc877e7-ccba-4a52-83bd-b3b57af7fd7f.png</url>
      <title>DEV Community: Reinhard Bonnke</title>
      <link>https://dev.to/reinhard_bonnke_3c96981a4</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/reinhard_bonnke_3c96981a4"/>
    <language>en</language>
    <item>
      <title>SQL Building Blocks: How Subqueries and CTEs Shape Your Data</title>
      <dc:creator>Reinhard Bonnke</dc:creator>
      <pubDate>Mon, 27 Apr 2026 22:04:46 +0000</pubDate>
      <link>https://dev.to/reinhard_bonnke_3c96981a4/sql-building-blocks-how-subqueries-and-ctes-shape-your-data-4b0j</link>
      <guid>https://dev.to/reinhard_bonnke_3c96981a4/sql-building-blocks-how-subqueries-and-ctes-shape-your-data-4b0j</guid>
      <description>&lt;p&gt;Unless you are new to SQL, at some point you have written a query that begins to resemble a puzzle box query, query within query, difficult to read, more difficult to debug. CTEs fix that.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;So, What is a CTE?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;CTE is an abbreviation that means &lt;strong&gt;Common Table Expression&lt;/strong&gt;. It is simply a means of assigning value to a query in order to be able to employ it later in the same statement like a table.&lt;br&gt;
It is the keyword &lt;code&gt;WITH&lt;/code&gt;.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8zp4aqqo42inb2lji0q5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8zp4aqqo42inb2lji0q5.png" alt=" " width="800" height="233"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the point of using one?
&lt;/h2&gt;

&lt;p&gt;Readability. Your SQL is top down rather than inwards.&lt;br&gt;
Reusability. You need not rewrite the query, you can refer to the same CTE more than once.&lt;br&gt;
Easier debugging. You can even do CTE alone which would check what it is returning. &lt;/p&gt;

&lt;h2&gt;
  
  
  What is the Difference Between CTEs and Subqueries?
&lt;/h2&gt;

&lt;p&gt;The two are similar in that they allow you to work on a derived result set. But they feel very different to write and read.&lt;br&gt;
The following query expressed in either direction:&lt;br&gt;
Subquery:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1bei4jc6izq0uk3reuv5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1bei4jc6izq0uk3reuv5.png" alt=" " width="800" height="191"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;There are one thing subqueries that can do but not CTEs.&lt;/strong&gt;&lt;br&gt;
A correlated sub query is able to reference the outer query. CTEs can't do that.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu5b8wx0qp5laldg8hj1s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu5b8wx0qp5laldg8hj1s.png" alt=" " width="800" height="184"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, the e.department_id is the reference that is correlatedand recalculated on a per row basis. CTEs are determined in advance of the main query, and thus can do nothing to do this.&lt;/p&gt;

&lt;h3&gt;
  
  
  Side-by-Side Comparison
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;CTE&lt;/th&gt;
&lt;th&gt;Subquery&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Readability&lt;/td&gt;
&lt;td&gt;Reads top to bottom&lt;/td&gt;
&lt;td&gt;Nested, harder to follow&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reusability&lt;/td&gt;
&lt;td&gt;Reference it multiple times&lt;/td&gt;
&lt;td&gt;Have to rewrite it each time&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Recursion&lt;/td&gt;
&lt;td&gt;✅ Supported&lt;/td&gt;
&lt;td&gt;❌ Not possible&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Correlated queries&lt;/td&gt;
&lt;td&gt;❌ Can't reference outer query&lt;/td&gt;
&lt;td&gt;✅ Can reference outer query&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Works everywhere&lt;/td&gt;
&lt;td&gt;All modern databases&lt;/td&gt;
&lt;td&gt;Universal&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Subqueries can appear in 3 different Clauses
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;In SELECT: adds a computed column. Runs once per row, so can be slow on large data.&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhpvry3o58uc7w1sbh4ai.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhpvry3o58uc7w1sbh4ai.png" alt=" " width="800" height="105"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;In FROM: creates a temporary table. Always give it an alias.&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg10zxryw4if4tfs7cdkn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg10zxryw4if4tfs7cdkn.png" alt=" " width="800" height="190"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;In WHERE: filters based on another query's result.&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyfwdfhr07p6nl0zkaods.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyfwdfhr07p6nl0zkaods.png" alt=" " width="800" height="98"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  When to Use Which:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use a CTE when:&lt;/strong&gt;&lt;br&gt;
There are several steps to your query.&lt;br&gt;
You want your SQL serving as easy to read and maintain.&lt;br&gt;
You must cite the same finding more than twice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use a sub query in circumstances where:&lt;/strong&gt;&lt;br&gt;
It is a fast and easy filter.&lt;br&gt;
You must have a correlated query (which cites the outer query).&lt;br&gt;
You are filtering in a WHERE or HAVING statement.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reflection
&lt;/h2&gt;

&lt;p&gt;The CTEs and subqueries were indeed one of the more difficult things I have learned so far. Originally, the syntax was foreign  particularly where each segment resides and why. Queries that contained a subquery and nested queries were especially difficult to reason and read. CTEs simplified it because it dawned on me that you are just giving a query a name and calling it a table. The most difficult was not writing the queries but understanding which tool to consult and why. It was beginning to trade sense after I had practiced and had gone through examples. They are a work in progress, but the comprehension is approaching.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>sql</category>
      <category>postgres</category>
      <category>data</category>
    </item>
    <item>
      <title>SQL Basics: DDL, DML, Filtering &amp; Data Transformation</title>
      <dc:creator>Reinhard Bonnke</dc:creator>
      <pubDate>Mon, 13 Apr 2026 10:41:11 +0000</pubDate>
      <link>https://dev.to/reinhard_bonnke_3c96981a4/sql-basics-ddl-dml-filtering-data-transformation-2301</link>
      <guid>https://dev.to/reinhard_bonnke_3c96981a4/sql-basics-ddl-dml-filtering-data-transformation-2301</guid>
      <description>&lt;p&gt;SQL is a standard language that is used to communicate with relational databases. In simple terms, it is the way in which you speak to a database to get data, write new data, alter existing data, delete data, grant access, and determine the structure of your database.&lt;br&gt;
SQL statements can be classified into groups of what they do:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Category&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;DQL&lt;/strong&gt; – Data Query Language&lt;/td&gt;
&lt;td&gt;Retrieve data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;DML&lt;/strong&gt; – Data Manipulation Language&lt;/td&gt;
&lt;td&gt;Modify data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;DDL&lt;/strong&gt; – Data Definition Language&lt;/td&gt;
&lt;td&gt;Define database structure&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;DCL&lt;/strong&gt; – Data Control Language&lt;/td&gt;
&lt;td&gt;Control access&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;TCL&lt;/strong&gt; – Transaction Control Language&lt;/td&gt;
&lt;td&gt;Manage transactions&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This week, I focused on two of these: DDL and DML.&lt;br&gt;
What’s the Difference Between DDL and DML?&lt;br&gt;
DDL is about structure where, it defines and sets up the database itself. Think of it as building a house before moving the furniture in.&lt;br&gt;
DML is about data; It is what you use once the structure exists to add, change, or remove information inside it.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;DDL&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;DML&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;What it does&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Defines structure&lt;/td&gt;
&lt;td&gt;Modifies data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Commands&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Create, Drop, Alter, Rename, Truncate&lt;/td&gt;
&lt;td&gt;Insert, Update, Delete&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Affects&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Tables and Schemas&lt;/td&gt;
&lt;td&gt;Rows/Records&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;How I Used DDL and DML in My Assignment&lt;br&gt;
CREATE: Building the Table (DDL)&lt;/strong&gt;&lt;br&gt;
The first thing I did was create a table to hold the data. &lt;code&gt;CREATE&lt;/code&gt; sets up the table and defines what columns it will have and what type of data each column accepts.&lt;br&gt;
For example, after having created my schema, I set the path to the name of my current schema and then proceeded to create the table using command ‘Create.’&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq8mej9mznwwi91hg8auc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq8mej9mznwwi91hg8auc.png" alt=" " width="800" height="184"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;INSERT: Adding Data (DML)&lt;/strong&gt;&lt;br&gt;
Once the table existed, I populated it with records using &lt;code&gt;INSERT&lt;/code&gt;.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9fm0i296yvc67playo9k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9fm0i296yvc67playo9k.png" alt=" " width="800" height="234"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;UPDATE: Editing Existing Records (DML)&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;UPDATE&lt;/code&gt; lets you change data that is already in the table without deleting and re-entering everything.&lt;br&gt;
For example, changing the City to Nairobi having made an entry of City as Mombasa;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9vuq53gxajj3sfl3w1oz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9vuq53gxajj3sfl3w1oz.png" alt=" " width="800" height="108"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DELETE: Removing Records (DML)&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;DELETE&lt;/code&gt; removes specific rows from the table. Used carefully, it's a clean way to get rid of records you no longer need.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcqexerhoym53xogcm7pm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcqexerhoym53xogcm7pm.png" alt=" " width="800" height="92"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Filtering with WHERE&lt;/strong&gt;&lt;br&gt;
The &lt;code&gt;WHERE&lt;/code&gt; clause lets you target specific rows instead of affecting or retrieving everything. Here are some common operators I used:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Operator&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;=&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Exact match&lt;/td&gt;
&lt;td&gt;&lt;code&gt;WHERE city = 'Nairobi'&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Greater than&lt;/td&gt;
&lt;td&gt;&lt;code&gt;WHERE marks &amp;gt; 70&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;BETWEEN&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Within a range&lt;/td&gt;
&lt;td&gt;&lt;code&gt;WHERE marks BETWEEN 50 AND 80&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;IN&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Matches a list&lt;/td&gt;
&lt;td&gt;&lt;code&gt;WHERE status IN ('Active', 'Pending')&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;LIKE&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Partial match&lt;/td&gt;
&lt;td&gt;&lt;code&gt;WHERE name LIKE 'A%'&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For example, take a look of the following;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fykjknbkdd8m8a3ovbz5u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fykjknbkdd8m8a3ovbz5u.png" alt=" " width="800" height="230"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CASE WHEN: Transforming Data on the Fly&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;CASE WHEN&lt;/code&gt; works like an IF statement. It lets you create a new column based on conditions, without changing the original data.&lt;br&gt;
For example, you can label students as "Senior" or “Junior” based on their class right inside your query.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F95b0rb3twfsv1ee3w7eq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F95b0rb3twfsv1ee3w7eq.png" alt=" " width="800" height="161"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My Reflection&lt;/strong&gt;&lt;br&gt;
The section which was of most interest to me was CASE WHEN. It was as though SQL had ceased to be simply about data storage, and began to become about processing that data. You are actually making choices within a query that seems strong considering something so simplistic.&lt;br&gt;
I was challenged by getting WHERE conditions correct which were particularly the combination of multiple operators. Even a minor syntax error, a lost quote, an incorrect operator and the entire query fails. However, that is what made it satisfying as well when it did finally work.&lt;br&gt;
SQL is beginning to disintegrate into a programming language and more of a logic of the data.&lt;/p&gt;

</description>
      <category>learning</category>
      <category>sql</category>
      <category>sqlserver</category>
      <category>datascience</category>
    </item>
    <item>
      <title>How Excel is Used in Real-World Data Analysis</title>
      <dc:creator>Reinhard Bonnke</dc:creator>
      <pubDate>Fri, 27 Mar 2026 13:52:13 +0000</pubDate>
      <link>https://dev.to/reinhard_bonnke_3c96981a4/how-excel-is-used-in-real-world-data-analysis-43hk</link>
      <guid>https://dev.to/reinhard_bonnke_3c96981a4/how-excel-is-used-in-real-world-data-analysis-43hk</guid>
      <description>&lt;h1&gt;
  
  
  How Excel is Used in Real-World Data Analysis
&lt;/h1&gt;

&lt;p&gt;We all have heard the word Excel a lot in job descriptions, co-workers and maybe even in your data course. But what does it actually do? And how come that so many data-related positions trust in it?&lt;/p&gt;

&lt;p&gt;Let us reduce it down to simple, practical and real illustrations&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;What is Excel?&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;Excel is a spreadsheet program provided by Microsoft. Consider it as a huge, intelligent table within which it is possible to store data, calculate and identify patterns, and construct reports all in a single table.&lt;br&gt;
Accountants, analysts, and marketers as well as HR teams and any person, who has to deal with numbers and lists on a regular basis use it.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The Excel Interface: What you are looking at.&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The view you will get on opening excel is as follows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffpbw41oudpkkfmulz5nc.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffpbw41oudpkkfmulz5nc.PNG" alt=" " width="800" height="120"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ribbon: The toolbar at the top. Everything lives here: formatting, formulas, charts, etc.&lt;br&gt;
Formula Bar: Shows what's inside the cell you've selected.&lt;br&gt;
Name Box: Tells you which cell is selected (e.g., A1).&lt;br&gt;
Columns, Rows &amp;amp; Cells: The building blocks of your spreadsheet&lt;br&gt;
Worksheet Tabs: Different sheets within the same file.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The 3 Types of Data in Excel:&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Before you do anything, you need to understand what kind of data you're working with:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Data Type&lt;/th&gt;
&lt;th&gt;Examples&lt;/th&gt;
&lt;th&gt;Alignment&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Text&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;"John", "Nairobi"&lt;/td&gt;
&lt;td&gt;Left&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Dates&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;01/01/2024&lt;/td&gt;
&lt;td&gt;Right&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Numbers&lt;/td&gt;
&lt;td&gt;100, 35, 3.5&lt;/td&gt;
&lt;td&gt;Right&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The alignment detail is significant, a fast method to check if something has been typed in wrong (e.g. a date appearing left-aligned is actually a text, not a date).&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Data Cleaning&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Cleaning the Data First
&lt;/h3&gt;

&lt;p&gt;Real-world data is messy. You clean it before it is analyzed. This is referred to as &lt;strong&gt;data cleaning&lt;/strong&gt;, involcing repairing errors, blanks as well as inconsistencies in order to make data actually useful.&lt;/p&gt;

&lt;p&gt;Here is what that looks like in practice:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Eliminate duplicates:&lt;/strong&gt; Excel has got an inbuilt option.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7eakt9hen5srn98ioxmt.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7eakt9hen5srn98ioxmt.PNG" alt=" " width="330" height="130"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Handling missing values:&lt;/strong&gt; In some cases, it is good to delete a row or column of more than 60% of the data is missing; or replace it with mean/mode/median. Also, you can replace it with “Unknown” or “Not Provided.”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Correct errors:&lt;/strong&gt; n case one row contains the word nairobi and another contains Nairobi, excel considers them different. Standardize with Find and replace or text tools.&lt;br&gt;
&lt;strong&gt;Eliminate blatant mistakes&lt;/strong&gt; like when the majority of a column are 50-80 and one reflects a 2 it is worth examining rather than trying to put in your analysis.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step 2: Sorting &amp;amp; Filtering&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;After data is clean, you should then find your way through it. Filtering and sorting allow you to narrow down on what is important.&lt;br&gt;
Sort numbers smallest → largest, dates oldest → newest, or text A → Z&lt;br&gt;
Filter to show only rows that match a condition (e.g., only sales from Q1, only customers from Nairobi)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4d1phieyhslk0b06wy1h.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4d1phieyhslk0b06wy1h.PNG" alt=" " width="190" height="90"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Using Functions
&lt;/h3&gt;

&lt;p&gt;This is where Excel gets powerful. Functions are built-in formulas that do the heavy lifting for you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Basic Math Function&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;=SUM(B2:B10) - Adds up a range&lt;br&gt;
=AVERAGE(B2:B10) - Finds the average&lt;br&gt;
=MAX(B2:B10) - Finds the highest value&lt;br&gt;
=MIN(B2:B10) - Finds the lowest value&lt;br&gt;
=COUNT(B2:B10) - Counts how many entries exist&lt;br&gt;
=COUNTIF(B2:B10, "&amp;gt;50") - Counts entries above 50&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Text Functions (Super useful for cleaning)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;=UPPER("nairobi") - NAIROBI&lt;br&gt;
=LOWER("NAIROBI") - nairobi&lt;br&gt;
=PROPER("nairobi") - Nairobi&lt;br&gt;
=TRIM("  hello  ") - hello  (removes extra spaces)&lt;br&gt;
=LEN("hello") - 5  (counts characters)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Date Functions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;=TODAY() - Today's date&lt;br&gt;
=YEAR(A2) - Extracts the year from a date&lt;br&gt;
=DAY(A2) - Extracts the day&lt;br&gt;
=DATEDIF(A2,B2,"D") - Number of days between two dates&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Logical Functions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;=IF(C2&amp;gt;50, "Pass", "Fail") - Simple condition&lt;br&gt;
=IF(AND(C2&amp;gt;50, D2="Paid"), "OK", "Check") - Multiple conditions&lt;/p&gt;

&lt;h3&gt;
  
  
  Lookup Functions
&lt;/h3&gt;

&lt;p&gt;VLOOKUP lets you search for a value in one column and pull related data from another. Think of it like a search engine within your spreadsheet.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Conditional Formatting
&lt;/h3&gt;

&lt;p&gt;Conditional formatting changes how a cell looks based on its value. For example, cells below a threshold turn red, top performers turn green.&lt;br&gt;
The goal is simple: see data, understand it, act on it, without staring at rows of numbers. For example, look at the column below and spot the difference;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7kmoribxydcgjftpbej3.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7kmoribxydcgjftpbej3.PNG" alt=" " width="320" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Pivot Tables
&lt;/h2&gt;

&lt;p&gt;An overview of massive data can be created in a few seconds by a Pivot Table. You do not need to write up complicated formulas, you simply use your mouse and move around fields to group, count or add data.&lt;br&gt;
For example: You are having 500 rows of sales knowledge. You can immediately see the total sales by region, sales by month or product without even data entry into a formula with a Pivot table.&lt;/p&gt;

&lt;p&gt;Take a look at this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbex32g9olrd8sgj88y6u.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbex32g9olrd8sgj88y6u.PNG" alt=" " width="407" height="398"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Charts: Telling the Story Visually
&lt;/h2&gt;

&lt;p&gt;Numbers make sense to analysts. Charts make sense to everyone else.&lt;/p&gt;

&lt;p&gt;Common chart types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bar/Column:&lt;/strong&gt; Compare categories&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Line:&lt;/strong&gt; Show trends over time&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pie:&lt;/strong&gt; Show proportions (use sparingly)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is an example of a Pie chart:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjgwqd2eh6257zj0sfnen.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjgwqd2eh6257zj0sfnen.PNG" alt=" " width="800" height="289"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, here is an example of  Bar Graph:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzm4yhv2sso5x4qxvh61e.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzm4yhv2sso5x4qxvh61e.PNG" alt=" " width="800" height="260"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;My Personal Reflection&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Honestly, prior to learning Excel, I believed that the process of data analysis happened in dreamy software with incomprehensible code. Excel transformed that presumption within a short period.&lt;br&gt;
I was most shocked by the extent to which you can accomplish without analysis having begun, simple cleaning of data, error checks, harmonization of formats. That was something that did not seem to me before, and now I notice it everywhere. And once a report or a spreadsheet is presented I unconsciously begin to ask myself: Is the data clean? Are there missing values? Does this make sense?&lt;br&gt;
The learning process similar to those of COUNTIF, IF and VLOOKUP also changed my thinking pattern.&lt;br&gt;
The most significant thing that Excel has provided me is that mental change of going to do things manually instead of thinking in a systematic manner.&lt;br&gt;
It is not just a tool. It is a mental process towards information!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>productivity</category>
      <category>tutorial</category>
      <category>writing</category>
    </item>
  </channel>
</rss>
