<?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>Forem: DataLane </title>
    <description>The latest articles on Forem by DataLane  (@datalane).</description>
    <link>https://forem.com/datalane</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%2F1868947%2F0e16a8ae-4a4d-4f31-8735-b85986d40fc0.png</url>
      <title>Forem: DataLane </title>
      <link>https://forem.com/datalane</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/datalane"/>
    <language>en</language>
    <item>
      <title>The Ultimate Guide to SQL Joins and Subqueries Explained</title>
      <dc:creator>DataLane </dc:creator>
      <pubDate>Mon, 08 Sep 2025 05:36:51 +0000</pubDate>
      <link>https://forem.com/datalane/the-ultimate-guide-to-sql-joins-and-subqueries-explained-a48</link>
      <guid>https://forem.com/datalane/the-ultimate-guide-to-sql-joins-and-subqueries-explained-a48</guid>
      <description>&lt;p&gt;If you’re following along with my SQL Series, welcome to Part 2 🎉 🎉&lt;/p&gt;

&lt;p&gt;In the first part, we focused on the basics of retrieving and filtering data from a single table. Now, we’re taking the next big step: learning how to work with data spread across multiple tables.&lt;/p&gt;

&lt;p&gt;We’ll break down the different types of joins, look at practical use cases, and then explore how subqueries can make your queries more flexible and easier to maintain.&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%2Fofnfrjsqo3c2dv76y3vi.gif" 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%2Fofnfrjsqo3c2dv76y3vi.gif" alt="GIF" width="480" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What are SQL JOINS?
&lt;/h2&gt;

&lt;p&gt;In relational databases, data is often stored across multiple normalized tables. For example, &lt;em&gt;employees&lt;/em&gt; and &lt;em&gt;departments&lt;/em&gt; might live in two separate tables. But in real-world business queries, you almost always need combined information.&lt;/p&gt;

&lt;p&gt;A JOIN in SQL allows you to query data from two or more tables based on a related column between them (often a primary key and foreign key relationship).&lt;/p&gt;

&lt;p&gt;Syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT column_list
FROM table1
JOIN table2
ON table1.common_column = table2.common_column;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  When to Use JOINS
&lt;/h2&gt;

&lt;p&gt;JOINS should be used when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your data is normalized into multiple tables (e.g., Customers, Orders, Products).&lt;/li&gt;
&lt;li&gt;You want to generate comprehensive reports combining multiple entities (e.g., customer details + their purchases).&lt;/li&gt;
&lt;li&gt;You need data validation, ensuring only matching records across tables are retrieved.&lt;/li&gt;
&lt;li&gt;You’re building reports or dashboards where relationships between entities matter.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Different Types of SQL JOINs
&lt;/h2&gt;

&lt;p&gt;Here are the main types of joins in SQL:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;INNER JOIN → Returns records that have matching values in both tables&lt;/li&gt;
&lt;li&gt;LEFT (OUTER) JOIN → Returns all records from the left table, and the matched records from the right table&lt;/li&gt;
&lt;li&gt;RIGHT (OUTER) JOIN → Returns all records from the right table, and the matched records from the left table&lt;/li&gt;
&lt;li&gt;FULL (OUTER) JOIN → Returns all records when there is a match in either left or right table&lt;/li&gt;
&lt;li&gt;CROSS JOIN → represents the Cartesian product (all combinations).&lt;/li&gt;
&lt;/ol&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%2Fp33y7qmgcqlvfljt75t6.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%2Fp33y7qmgcqlvfljt75t6.png" alt="Types of Joins" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example Dataset:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For this guide, we’ll be working with a classic use case that most organizations deal with throughout. &lt;/p&gt;

&lt;p&gt;We’ll use two main tables:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Employees &lt;/li&gt;
&lt;li&gt;Departments&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;employee_id&lt;/th&gt;
&lt;th&gt;name&lt;/th&gt;
&lt;th&gt;department_id&lt;/th&gt;
&lt;th&gt;salary&lt;/th&gt;
&lt;th&gt;hire_date&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Alice&lt;/td&gt;
&lt;td&gt;101&lt;/td&gt;
&lt;td&gt;70000&lt;/td&gt;
&lt;td&gt;2019-01-15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Bob&lt;/td&gt;
&lt;td&gt;102&lt;/td&gt;
&lt;td&gt;55000&lt;/td&gt;
&lt;td&gt;2020-03-12&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Charlie&lt;/td&gt;
&lt;td&gt;NULL&lt;/td&gt;
&lt;td&gt;40000&lt;/td&gt;
&lt;td&gt;2018-07-23&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Diana&lt;/td&gt;
&lt;td&gt;103&lt;/td&gt;
&lt;td&gt;62000&lt;/td&gt;
&lt;td&gt;2017-09-10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;Ethan&lt;/td&gt;
&lt;td&gt;101&lt;/td&gt;
&lt;td&gt;72000&lt;/td&gt;
&lt;td&gt;2021-06-19&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;Farah&lt;/td&gt;
&lt;td&gt;104&lt;/td&gt;
&lt;td&gt;58000&lt;/td&gt;
&lt;td&gt;2022-02-14&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;George&lt;/td&gt;
&lt;td&gt;NULL&lt;/td&gt;
&lt;td&gt;45000&lt;/td&gt;
&lt;td&gt;2016-11-05&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;department_id&lt;/th&gt;
&lt;th&gt;department_name&lt;/th&gt;
&lt;th&gt;location&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;101&lt;/td&gt;
&lt;td&gt;HR&lt;/td&gt;
&lt;td&gt;New York&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;102&lt;/td&gt;
&lt;td&gt;IT&lt;/td&gt;
&lt;td&gt;San Francisco&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;103&lt;/td&gt;
&lt;td&gt;Marketing&lt;/td&gt;
&lt;td&gt;Chicago&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;104&lt;/td&gt;
&lt;td&gt;Finance&lt;/td&gt;
&lt;td&gt;Boston&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;105&lt;/td&gt;
&lt;td&gt;Operations&lt;/td&gt;
&lt;td&gt;Dallas&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Have a look at the tables and the data, were you able to catch any gaps? If not, don't worry I got you. &lt;/p&gt;

&lt;h3&gt;
  
  
  INNER JOIN
&lt;/h3&gt;

&lt;p&gt;When we perform a simple JOIN our result only includes rows that match our &lt;code&gt;ON&lt;/code&gt; condition.&lt;/p&gt;

&lt;p&gt;👉 Example: Find all employees who are assigned to a valid department.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT e.name, e.salary, d.department_name, d.location
FROM employees e
INNER JOIN departments d
ON e.department_id = d.department_id;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output: &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;name&lt;/th&gt;
&lt;th&gt;salary&lt;/th&gt;
&lt;th&gt;department_name&lt;/th&gt;
&lt;th&gt;location&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Alice&lt;/td&gt;
&lt;td&gt;70000&lt;/td&gt;
&lt;td&gt;HR&lt;/td&gt;
&lt;td&gt;New York&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bob&lt;/td&gt;
&lt;td&gt;55000&lt;/td&gt;
&lt;td&gt;IT&lt;/td&gt;
&lt;td&gt;San Francisco&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Diana&lt;/td&gt;
&lt;td&gt;62000&lt;/td&gt;
&lt;td&gt;Marketing&lt;/td&gt;
&lt;td&gt;Chicago&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ethan&lt;/td&gt;
&lt;td&gt;72000&lt;/td&gt;
&lt;td&gt;HR&lt;/td&gt;
&lt;td&gt;New York&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Farah&lt;/td&gt;
&lt;td&gt;58000&lt;/td&gt;
&lt;td&gt;Finance&lt;/td&gt;
&lt;td&gt;Boston&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: &lt;code&gt;INNER&lt;/code&gt; is the default, so &lt;code&gt;JOIN&lt;/code&gt; is equivalent to &lt;code&gt;INNER JOIN&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  LEFT JOIN
&lt;/h3&gt;

&lt;p&gt;Returns all rows from the left table (employees), even if they don’t have a matching row from the right table (department).&lt;/p&gt;

&lt;p&gt;If no match exists, the right-side columns return &lt;code&gt;NULL&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;👉 Example: List all employees, including those without departments.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT e.name, e.salary, d.department_name
FROM employees e
LEFT JOIN departments d
ON e.department_id = d.department_id;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output: &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;name&lt;/th&gt;
&lt;th&gt;salary&lt;/th&gt;
&lt;th&gt;department_name&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Alice&lt;/td&gt;
&lt;td&gt;70000&lt;/td&gt;
&lt;td&gt;HR&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bob&lt;/td&gt;
&lt;td&gt;55000&lt;/td&gt;
&lt;td&gt;IT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Charlie&lt;/td&gt;
&lt;td&gt;40000&lt;/td&gt;
&lt;td&gt;NULL&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Diana&lt;/td&gt;
&lt;td&gt;62000&lt;/td&gt;
&lt;td&gt;Marketing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ethan&lt;/td&gt;
&lt;td&gt;72000&lt;/td&gt;
&lt;td&gt;HR&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Farah&lt;/td&gt;
&lt;td&gt;58000&lt;/td&gt;
&lt;td&gt;Finance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;George&lt;/td&gt;
&lt;td&gt;45000&lt;/td&gt;
&lt;td&gt;NULL&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  RIGHT JOIN
&lt;/h3&gt;

&lt;p&gt;A RIGHT JOIN returns all rows from the right table(department), plus matching rows from the left(employees). &lt;/p&gt;

&lt;p&gt;If no match exists, the left-side columns return &lt;code&gt;NULL&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;👉 Example: List all departments, including those without employees.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT e.name, d.department_name
FROM employees e
RIGHT JOIN departments d
ON e.department_id = d.department_id;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output: &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;name&lt;/th&gt;
&lt;th&gt;department_name&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Alice&lt;/td&gt;
&lt;td&gt;HR&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ethan&lt;/td&gt;
&lt;td&gt;HR&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bob&lt;/td&gt;
&lt;td&gt;IT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Diana&lt;/td&gt;
&lt;td&gt;Marketing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Farah&lt;/td&gt;
&lt;td&gt;Finance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NULL&lt;/td&gt;
&lt;td&gt;Operations&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  FULL OUTER JOIN
&lt;/h3&gt;

&lt;p&gt;Returns all records when there is a match in left (employees) or right (departments) table records.&lt;/p&gt;

&lt;p&gt;Use FULL OUTER JOIN when you want a complete picture of employees and departments, including mismatches on both sides.&lt;/p&gt;

&lt;p&gt;👉 Example: Show a complete view of employees and departments, including unmatched rows on both sides.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT e.name, d.department_name
FROM employees e
FULL OUTER JOIN departments d
ON e.department_id = d.department_id;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output: &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;name&lt;/th&gt;
&lt;th&gt;department_name&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Alice&lt;/td&gt;
&lt;td&gt;HR&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ethan&lt;/td&gt;
&lt;td&gt;HR&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bob&lt;/td&gt;
&lt;td&gt;IT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Diana&lt;/td&gt;
&lt;td&gt;Marketing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Farah&lt;/td&gt;
&lt;td&gt;Finance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Charlie&lt;/td&gt;
&lt;td&gt;NULL&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;George&lt;/td&gt;
&lt;td&gt;NULL&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NULL&lt;/td&gt;
&lt;td&gt;Operations&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: &lt;code&gt;FULL OUTER JOIN&lt;/code&gt; and &lt;code&gt;FULL JOIN&lt;/code&gt; are equivalent.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  CROSS JOIN
&lt;/h3&gt;

&lt;p&gt;Returns the Cartesian product of both tables (every employee with every department).&lt;/p&gt;

&lt;p&gt;It is rarely used in business queries, but useful for generating test data or combinations.&lt;/p&gt;

&lt;p&gt;👉 List all employee-department combinations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT e.name, d.department_name
FROM employees e
CROSS JOIN departments d;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice that cross joins don’t require an &lt;code&gt;ON&lt;/code&gt; statement. You’re not really joining on any columns!&lt;/p&gt;

&lt;h3&gt;
  
  
  UNION
&lt;/h3&gt;

&lt;p&gt;Sometimes we just want to stack one dataset on top of the other. Well, the &lt;code&gt;UNION&lt;/code&gt; operator allows us to do that.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;UNION&lt;/code&gt; operator automatically removes duplicate rows from the result set.&lt;/p&gt;

&lt;p&gt;Syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT *
FROM table1
UNION
SELECT *
FROM table2;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;SQL has strict rules for appending data:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tables must have the same number of columns.&lt;/li&gt;
&lt;li&gt;The columns must have the same data types in the same order as the first table.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Primary Key vs Foreign Key
&lt;/h3&gt;

&lt;p&gt;Relational databases are built on the idea of relationships between tables. These relationships are created using primary keys and foreign keys.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Primary Key:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A Primary Key is a column (or set of columns) that uniquely identifies each row in a table.&lt;/li&gt;
&lt;li&gt;No two rows can have the same primary key value.&lt;/li&gt;
&lt;li&gt;It cannot contain &lt;code&gt;NULL&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In the Departments table above, &lt;code&gt;department_id&lt;/code&gt; is the primary key because each department must have a unique ID.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Foreign Key:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A Foreign Key is a column in one table that refers to the primary key in another table.&lt;/li&gt;
&lt;li&gt;It creates the relationship between two tables.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In the Employees table, &lt;code&gt;department_id&lt;/code&gt; is a foreign key referencing the Departments table.&lt;/p&gt;

&lt;p&gt;Without primary and foreign keys, JOINS wouldn’t know how to link tables together.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using WITH in SQL
&lt;/h3&gt;

&lt;p&gt;Sometimes we want to combine two tables, but one of those tables isn’t available directly, instead, it’s the result of another calculation.&lt;/p&gt;

&lt;p&gt;For example, HR might want to know:&lt;/p&gt;

&lt;p&gt;👉 What is the average salary per department, and which employees belong to those departments?&lt;/p&gt;

&lt;p&gt;This requires two steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;First, calculate the average salary for each department.&lt;/li&gt;
&lt;li&gt;Then, join this result with the Employees table so we can see which employees belong to those departments. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Step 1: Calculate average salary per department&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT department_id,
       AVG(salary) AS avg_salary
FROM employees
GROUP BY department_id;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output: &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;department_id&lt;/th&gt;
&lt;th&gt;avg_salary&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;101&lt;/td&gt;
&lt;td&gt;71000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;102&lt;/td&gt;
&lt;td&gt;55000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;103&lt;/td&gt;
&lt;td&gt;62000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;104&lt;/td&gt;
&lt;td&gt;58000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NULL&lt;/td&gt;
&lt;td&gt;42500&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Step 2: Use WITH to build a reusable result&lt;/p&gt;

&lt;p&gt;Instead of nesting the above query directly, we wrap it with a CTE:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WITH dept_avg AS (
    SELECT department_id,
           AVG(salary) AS avg_salary
    FROM employees
    GROUP BY department_id
)
SELECT e.name, e.salary, d.department_name, dept_avg.avg_salary
FROM employees e
JOIN departments d
  ON e.department_id = d.department_id
JOIN dept_avg
  ON e.department_id = dept_avg.department_id;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output: &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;name&lt;/th&gt;
&lt;th&gt;salary&lt;/th&gt;
&lt;th&gt;department_name&lt;/th&gt;
&lt;th&gt;avg_salary&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Alice&lt;/td&gt;
&lt;td&gt;70000&lt;/td&gt;
&lt;td&gt;HR&lt;/td&gt;
&lt;td&gt;71000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ethan&lt;/td&gt;
&lt;td&gt;72000&lt;/td&gt;
&lt;td&gt;HR&lt;/td&gt;
&lt;td&gt;71000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bob&lt;/td&gt;
&lt;td&gt;55000&lt;/td&gt;
&lt;td&gt;IT&lt;/td&gt;
&lt;td&gt;55000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Diana&lt;/td&gt;
&lt;td&gt;62000&lt;/td&gt;
&lt;td&gt;Marketing&lt;/td&gt;
&lt;td&gt;62000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Farah&lt;/td&gt;
&lt;td&gt;58000&lt;/td&gt;
&lt;td&gt;Finance&lt;/td&gt;
&lt;td&gt;58000&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;At this point in our SQL journey we know we can query a &lt;br&gt;
database to retrieve desired results. However, what happens when we query a database but we really only need a subset of the results returned? &lt;/p&gt;

&lt;p&gt;Let's explore the use of something called a &lt;strong&gt;subquery&lt;/strong&gt; that gives us the same functionality as a join, but with much more readability.&lt;/p&gt;
&lt;h2&gt;
  
  
  Subqueries
&lt;/h2&gt;

&lt;p&gt;As the name suggests, a subquery is an internal query nested inside of an external query. They can be nested inside of &lt;code&gt;SELECT&lt;/code&gt;, &lt;code&gt;INSERT&lt;/code&gt;, &lt;code&gt;UPDATE&lt;/code&gt;, or &lt;code&gt;DELETE&lt;/code&gt; statements. &lt;/p&gt;

&lt;p&gt;Anytime a subquery is present, it gets executed before the external statement is run.&lt;/p&gt;

&lt;p&gt;Syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT column1, column2, ...
FROM table1
WHERE column operator (SELECT column FROM table2 WHERE condition);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;column1, column2, ...&lt;/code&gt;: A list of column names you want to retrieve.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;table1&lt;/code&gt;: The main table from which you want to select data.&lt;/li&gt;
&lt;li&gt;column: The column you want to compare or filter against in the main query.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;operator&lt;/code&gt;: An operator such as =, &amp;gt;, &amp;lt;, IN, NOT IN, etc.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;table2&lt;/code&gt;: The table from which you want to retrieve data for comparison.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;condition&lt;/code&gt;: The condition that specifies which records to select from the subquery.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;When to use&lt;/strong&gt;: When you need to filter, calculate, or aggregate before applying conditions in your main query.&lt;/p&gt;

&lt;p&gt;👉 Example: Find employees earning more than the average salary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT name, salary
FROM employees
WHERE salary &amp;gt; (SELECT AVG(salary) FROM employees);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this statement, the subquery SELECT statement would be executed first, resulting in a list of average salaries of the employees.&lt;/p&gt;

&lt;h3&gt;
  
  
  Comparison Operators
&lt;/h3&gt;

&lt;p&gt;Subqueries are often combined with operators for filtering. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;=&lt;/strong&gt; → Equal to&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&amp;gt;&lt;/strong&gt; → Greater than&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&amp;lt;&lt;/strong&gt; → Less than&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&amp;gt;=&lt;/strong&gt; → Greater than or equal to&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&amp;lt;=&lt;/strong&gt; → Less than or equal to&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&amp;lt;&amp;gt;&lt;/strong&gt; or &lt;strong&gt;!=&lt;/strong&gt; → Not equal to&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  In and Not In Clauses
&lt;/h3&gt;

&lt;p&gt;The more common ways to use subqueries is with the use of an &lt;code&gt;IN&lt;/code&gt; or &lt;code&gt;NOT IN&lt;/code&gt; clause&lt;/p&gt;

&lt;p&gt;When an &lt;code&gt;IN&lt;/code&gt; clause is used, results retrieved from the external query must appear within the subquery results.&lt;/p&gt;

&lt;p&gt;Similarly, when a &lt;code&gt;NOT IN&lt;/code&gt; clause is used, results retrieved from the external query must not appear within the subquery results.&lt;/p&gt;

&lt;p&gt;Example (IN): Employees in HR or IT&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT name
FROM employees
WHERE department_id IN (101, 102);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Result&lt;/strong&gt;: Alice, Bob, Ethan&lt;/p&gt;

&lt;p&gt;Example (NOT IN): Employees not in HR or IT&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT name
FROM employees
WHERE department_id NOT IN (101, 102);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Result&lt;/strong&gt;: Charlie, Diana, Farah, George&lt;/p&gt;

&lt;h2&gt;
  
  
  Exists and Not Exists
&lt;/h2&gt;

&lt;p&gt;The EXISTS and NOT EXISTS clauses are used in SQL to test whether a subquery returns any rows.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EXISTS&lt;/strong&gt; → Returns &lt;code&gt;TRUE&lt;/code&gt; if the subquery produces at least one row.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOT EXISTS&lt;/strong&gt; → Returns &lt;code&gt;TRUE&lt;/code&gt; if the subquery produces no rows.&lt;/p&gt;

&lt;p&gt;Unlike IN / NOT IN, which collect a list of values from the subquery and then compare them, EXISTS simply checks for the presence of rows.&lt;/p&gt;

&lt;p&gt;Example: Show all employees who are assigned to a department.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT *
FROM employees e
WHERE EXISTS (
    SELECT *
    FROM departments d
    WHERE d.department_id = e.department_id
);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The subquery checks if a department exists with the same department_id as the employee.&lt;/li&gt;
&lt;li&gt;If it finds one, EXISTS is true and the employee is included.&lt;/li&gt;
&lt;li&gt;If not, that employee is skipped.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example: Show employees who are not assigned to any department.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT *
FROM employees e
WHERE NOT EXISTS (
    SELECT *
    FROM departments d
    WHERE d.department_id = e.department_id
);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;For each employee, the subquery checks the departments table.&lt;/li&gt;
&lt;li&gt;If no department matches the employee’s department_id, then NOT EXISTS returns true, and that employee appears in the result.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;Congratulations on taking another step in the SQL journey. 🙌&lt;/p&gt;

&lt;p&gt;In the next part of the series, we’ll build on this foundation to tackle even more advanced SQL concepts. &lt;/p&gt;

&lt;p&gt;Until then, here’s a friendly reminder that you’ve leveled up:&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%2Fxe0pdfh7q5zr6jd3xcmq.gif" 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%2Fxe0pdfh7q5zr6jd3xcmq.gif" alt="GIF" width="563" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>sql</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>database</category>
    </item>
    <item>
      <title>SQL for Data Professionals: From Basics to Advanced Analytics</title>
      <dc:creator>DataLane </dc:creator>
      <pubDate>Mon, 01 Sep 2025 10:09:12 +0000</pubDate>
      <link>https://forem.com/datalane/sql-for-data-professionals-from-basics-to-advanced-analytics-2nd1</link>
      <guid>https://forem.com/datalane/sql-for-data-professionals-from-basics-to-advanced-analytics-2nd1</guid>
      <description>&lt;p&gt;SQL (Structured Query Language) remains the backbone of data retrieval and manipulation in the world of relational databases.&lt;/p&gt;

&lt;p&gt;Whether you’re a data analyst, data engineer, or business intelligence professional, learning SQL unlocks the ability to explore data, uncover insights, and build analytics pipelines with ease.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In this article, part of our &lt;strong&gt;SQL Learning Series&lt;/strong&gt;, you’ll go from SQL basics to advanced SQL techniques using real-world examples.&lt;/p&gt;
&lt;/blockquote&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%2Fj04adwcgvowkr9ffz1r9.gif" 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%2Fj04adwcgvowkr9ffz1r9.gif" width="480" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a Relational Database Management System (RDBMS)?
&lt;/h2&gt;

&lt;p&gt;A relational database management system (RDBMS) is a program that allows you to create, update, and administer a relational database. &lt;/p&gt;

&lt;p&gt;Relational databases store data in tables(rows and columns). &lt;/p&gt;

&lt;p&gt;Relationships between tables are established using keys:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Primary Key (PK): Uniquely identifies each row in a table.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Foreign Key (FK): Refers to the primary key in another table to maintain relationships.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What the heck is SQL?
&lt;/h2&gt;

&lt;p&gt;SQL stands for &lt;strong&gt;Structured Query Language&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It’s declarative, meaning you tell the database what you want, and it figures out how to get it.&lt;/p&gt;

&lt;p&gt;Three core categories of SQL commands:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;DDL (Data Definition Language) → Create or modify database objects like tables(CREATE, ALTER).&lt;/li&gt;
&lt;li&gt;DML (Data Manipulation Language) → Insert, update, or delete data.&lt;/li&gt;
&lt;li&gt;DQL (Data Query Language) → Retrieve data with &lt;code&gt;SELECT&lt;/code&gt; queries.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These form the foundation for both data exploration and advanced analytics tasks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Writing Your First SQL Queries
&lt;/h2&gt;

&lt;p&gt;Let’s look at some beginner-friendly SQL commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE friends (
  id INTEGER,
  name TEXT,
  birthday DATE,
)
INSERT INTO friends (id, name, birthday) 
VALUES (1, 'Ororo Munroe', '1940-05-30');

SELECT * 
FROM friends;

UPDATE friends
SET name = 'Storm'
WHERE id = 1;

ALTER TABLE friends
ADD COLUMN email TEXT;

UPDATE friends
SET email = storm@codecademy.com
WHERE id = 1;

DELETE FROM friends
WHERE id = 1;

SELECT * 
FROM friends;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fs87bp6nwnqfux6xjj27a.gif" 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%2Fs87bp6nwnqfux6xjj27a.gif" alt="Snapshot of the table " width="480" height="343"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ah, don't worry, I'm going to explain it all like you're five: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;CREATE TABLE&lt;/code&gt; is a clause that tells SQL you want to create a new table.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;friends&lt;/code&gt; is the name of the table.&lt;/li&gt;
&lt;li&gt;(&lt;strong&gt;id INTEGER, name TEXT, birthday DATE&lt;/strong&gt;) is a list of parameters defining each column, or attribute in the table and its data type.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The &lt;code&gt;INSERT&lt;/code&gt; statement inserts a new row into a table:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;(id, name, age)&lt;/code&gt;&lt;/strong&gt; is a parameter identifying the columns that data will be inserted into.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;VALUES&lt;/code&gt;&lt;/strong&gt; is a clause that indicates the data being inserted.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;SELECT&lt;/code&gt; statements are used to fetch data from a database.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;*&lt;/code&gt; is a special wildcard character that allows you to select every column in a table without having to name each one individually.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;The &lt;code&gt;ALTER TABLE&lt;/code&gt; statement is used to add or modify table columns.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ADD COLUMN&lt;/code&gt; is a clause that lets you add a new column to a table.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;The &lt;code&gt;UPDATE&lt;/code&gt; statement edits a row in a table.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can use the &lt;code&gt;UPDATE&lt;/code&gt; statement when you want to change existing records.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;WHERE&lt;/code&gt; is a clause that indicates which row(s) to update with the new column value.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;The &lt;code&gt;DELETE FROM&lt;/code&gt; statement deletes one or more rows from a table.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;WHERE&lt;/code&gt; is a clause that lets you select which rows you want to delete.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Pro tip: SQL commands are not case-sensitive. &lt;code&gt;select = SELECT&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding Constraints for Data Integrity
&lt;/h2&gt;

&lt;p&gt;Constraints define rules for your data.&lt;/p&gt;

&lt;p&gt;Example: The statement below sets constraints on the &lt;code&gt;awards&lt;/code&gt; table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE awards (
   id INTEGER PRIMARY KEY,
   recipient TEXT NOT NULL,
   award_name TEXT DEFAULT 'Grammy'
);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;PRIMARY KEY → Uniquely identifies each record.&lt;/li&gt;
&lt;li&gt;NOT NULL → Prevents empty values.&lt;/li&gt;
&lt;li&gt;DEFAULT → Sets a fallback value if none is provided.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This ensures data stays accurate and consistent.&lt;/p&gt;

&lt;h2&gt;
  
  
  Database Indexes: Speeding Things Up
&lt;/h2&gt;

&lt;p&gt;Indexes are a powerful tool used in the background of a database to speed up querying. Simply put, an index is a pointer to data in a table.&lt;/p&gt;

&lt;p&gt;How are indexes created?&lt;/p&gt;

&lt;p&gt;In a database, data is stored in &lt;code&gt;rows&lt;/code&gt; which are organized into &lt;code&gt;tables&lt;/code&gt;. Each &lt;code&gt;row&lt;/code&gt; has a unique key which distinguishes it from all other rows and those keys are stored in an index for quick retrieval.&lt;/p&gt;

&lt;p&gt;When a new &lt;em&gt;row&lt;/em&gt; with a &lt;em&gt;unique key&lt;/em&gt; is added, the index updates automatically.&lt;/p&gt;

&lt;p&gt;However, sometimes we need to quickly look up data that isn’t stored as a key—for example, finding customers by &lt;code&gt;telephone number&lt;/code&gt;. Using a unique constraint isn’t suitable in such cases because multiple rows can share the same value. Instead, custom indexes can be created.&lt;/p&gt;

&lt;p&gt;Creating an index:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE INDEX &amp;lt;index_name&amp;gt;
ON &amp;lt;table_name&amp;gt; (column1, column2, ...)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This allows faster access to frequently queried columns even if they are not unique keys.&lt;/p&gt;

&lt;h2&gt;
  
  
  QUERIES
&lt;/h2&gt;

&lt;p&gt;One of the core purposes of the SQL language is to retrieve information stored in a database. This is commonly referred to as querying.&lt;/p&gt;

&lt;p&gt;We'll be using SQL commands to query a table of restaurants called 'quench' and generate insights out of it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Start by getting a feel for the &lt;code&gt;quench&lt;/code&gt; table:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT *
FROM quench;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fr3zef46mdr8tyosrpdef.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%2Fr3zef46mdr8tyosrpdef.png" alt="Quench Table" width="800" height="578"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Find Distinct Neighborhoods&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT DISTINCT neighborhood
FROM quench;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;DISTINCT&lt;/code&gt; removes duplicates, so each neighborhood appears only once.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let’s say you’re craving Chinese food. To see all restaurants serving Chinese cuisine:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT *
FROM quench
WHERE cuisine = 'Chinese';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;WHERE&lt;/code&gt; clause filters rows based on a condition.&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%2Fs8q56l5oxt9stvxeosy8.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%2Fs8q56l5oxt9stvxeosy8.png" alt="Chinese Restaurants" width="800" height="238"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Filter by Review Score&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Want restaurants rated 4 or higher?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT *
FROM quench
WHERE review &amp;gt;= 4;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Conditions can use comparison operators like &lt;strong&gt;=, &amp;gt;=, &amp;lt;, or &amp;lt;&amp;gt;&lt;/strong&gt; (not equal).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you want to find Italian restaurants with exactly three dollar signs:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT *
FROM quench
WHERE cuisine = 'Italian'
   AND price = '$$$';

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both conditions must be true for rows to be included.&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%2F0501b53b58236fxtld05.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%2F0501b53b58236fxtld05.png" alt="Italian cuisine with '$$$'" width="800" height="238"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Search by Partial Name&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's say you can’t remember the exact name of a restaurant you went to earlier but knows it contains the word ‘meatball’ in it.&lt;/p&gt;

&lt;p&gt;How will you find it?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT *
FROM quench
WHERE name LIKE '%meatball%';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;LIKE&lt;/code&gt; is a special operator used with the &lt;code&gt;WHERE&lt;/code&gt; clause to search for a specific pattern in a column.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;%&lt;/code&gt;is a wildcard character that matches zero or more missing characters in the pattern.&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%2Fzntcn48ehihzbjohkuf0.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%2Fzntcn48ehihzbjohkuf0.png" alt="Search by Partial Name" width="800" height="74"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Filter by Multiple Locations&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Find all the close by spots in &lt;code&gt;Midtown&lt;/code&gt;, &lt;code&gt;Downtown&lt;/code&gt; or &lt;code&gt;Chinatown&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT name, cuisine, neighborhood
FROM quench
WHERE neighborhood = 'Midtown'
   OR neighborhood = 'Downtown'
   OR neighborhood = 'Chinatown'; 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: Operators like &lt;code&gt;OR/AND&lt;/code&gt; can be used more than once.&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%2Fombdwlthsv1ptakwyd9l.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%2Fombdwlthsv1ptakwyd9l.png" alt="close by spots" width="800" height="761"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We selected only &lt;code&gt;name&lt;/code&gt;, &lt;code&gt;cuisine&lt;/code&gt;, and &lt;code&gt;neighborhood&lt;/code&gt; for a concise result set.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Find Missing Health Grades.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT *
FROM quench
WHERE health IS NULL;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: &lt;code&gt;IS NULL&lt;/code&gt; checks for empty or missing values.&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%2Fdxtfvw5kohsd6f9dvnw0.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%2Fdxtfvw5kohsd6f9dvnw0.png" alt="Bad Health Grades" width="800" height="169"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Top 10 Restaurants by Reviews&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT *
FROM quench
ORDER BY review DESC
LIMIT 10;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;ORDER BY sorts results.&lt;/li&gt;
&lt;li&gt;DESC = descending order (highest first).&lt;/li&gt;
&lt;li&gt;LIMIT restricts the number of rows returned.&lt;/li&gt;
&lt;/ul&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%2Feqobzfc0c0iaygtahnt2.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%2Feqobzfc0c0iaygtahnt2.png" alt="Top 10 restaurants" width="800" height="285"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Woah! That was a lot to digest—literally. Now I’m craving some actual food!&lt;/p&gt;
&lt;/blockquote&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%2Fqcylhx6k2zuigrvlk20a.gif" 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%2Fqcylhx6k2zuigrvlk20a.gif" alt="GIF" width="480" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Aggregate Functions
&lt;/h2&gt;

&lt;p&gt;When working with databases, you often need more than just raw data ;you need insights. That’s where SQL aggregate functions come in. &lt;/p&gt;

&lt;p&gt;They allow you to perform calculations across multiple rows and return a single, meaningful result.&lt;/p&gt;

&lt;p&gt;Some of the most commonly used aggregate functions include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;COUNT() : count the number of rows&lt;/li&gt;
&lt;li&gt;SUM(): the sum of the values in a column&lt;/li&gt;
&lt;li&gt;MAX()/ MIN(): the largest/smallest value&lt;/li&gt;
&lt;li&gt;AVG(): the average of the values in a column&lt;/li&gt;
&lt;li&gt;ROUND(): round the values in the column&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In addition, you can use &lt;code&gt;GROUP BY&lt;/code&gt;, &lt;code&gt;ORDER BY&lt;/code&gt;, and &lt;code&gt;HAVING&lt;/code&gt; clauses to organize and filter aggregated data effectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine you own a chain of lemonade stands across different neighborhoods.&lt;/p&gt;

&lt;p&gt;Every day, each stand sells some cups of lemonade. At the end of the month, you want answers to questions like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How much lemonade did we sell each day?&lt;/li&gt;
&lt;li&gt;Which days were really good (sold more than 100 cups)?&lt;/li&gt;
&lt;li&gt;Which days made the most sales so we can study what went right?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In SQL terms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each stand’s daily sales = rows in our table&lt;/li&gt;
&lt;li&gt;Total cups sold per day = aggregate function (SUM)&lt;/li&gt;
&lt;li&gt;Filtering good days only = HAVING&lt;/li&gt;
&lt;li&gt;Sorting best days on top = ORDER BY&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Group the Sales Per Day (GROUP BY)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First, let’s sum up cups sold per day:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT date, SUM(cups_sold) AS total_cups
FROM sales
GROUP BY date;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here’s what happens:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;GROUP BY&lt;/code&gt; date → Puts all sales on the same day together&lt;br&gt;
&lt;code&gt;SUM(cups_sold)&lt;/code&gt; → Adds them up for each day&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Keep Only Good Days (HAVING)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now we only want days with at least 100 cups sold:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT 
    date,
    SUM(cups_sold) AS total_cups
FROM sales
GROUP BY date
HAVING SUM(cups_sold) &amp;gt;= 100;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;HAVING&lt;/code&gt; is like a filter for groups.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;WHERE&lt;/code&gt; filters rows before grouping, but &lt;code&gt;HAVING&lt;/code&gt; filters after aggregates are calculated.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Sort the Best Days (ORDER BY)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Finally, let’s sort days by total cups sold so the best days come first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT 
    date,
    SUM(cups_sold) AS total_cups
FROM sales
GROUP BY date
HAVING SUM(cups_sold) &amp;gt;= 100
ORDER BY total_cups DESC;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;In this post, we started with simple queries to explore data, then moved on to aggregate functions and powerful clauses like &lt;code&gt;GROUP BY&lt;/code&gt;, &lt;code&gt;HAVING&lt;/code&gt;, and &lt;code&gt;ORDER BY&lt;/code&gt; to summarize, filter, and sort results effectively.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Mastering these tools gives you the ability to:&lt;/li&gt;
&lt;li&gt;Spot trends quickly&lt;/li&gt;
&lt;li&gt;Summarize large datasets in seconds&lt;/li&gt;
&lt;li&gt;Filter and organize information with precision&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The next time you open a database, you’ll know exactly how to turn tables of numbers into actionable knowledge.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>datascience</category>
      <category>programming</category>
      <category>database</category>
    </item>
    <item>
      <title>Building a Data Career: The Skills That Truly Matter</title>
      <dc:creator>DataLane </dc:creator>
      <pubDate>Thu, 14 Aug 2025 06:17:20 +0000</pubDate>
      <link>https://forem.com/datalane/building-a-data-career-the-skills-that-truly-matter-3bcm</link>
      <guid>https://forem.com/datalane/building-a-data-career-the-skills-that-truly-matter-3bcm</guid>
      <description>&lt;p&gt;The need for people to understand, prioritize, manage, and analyze data is not slowing down in any industry. From quick trend analyses to advanced predictive modeling, businesses rely on data to guide strategic decisions and uncover opportunities.&lt;/p&gt;

&lt;p&gt;Data scientists and data analysts are on the front lines of this movement—gathering, cleaning, and interpreting information, then translating it into actionable insights for stakeholders.&lt;/p&gt;

&lt;p&gt;In short:&lt;/p&gt;

&lt;p&gt;What they do: Identify trends, patterns, and insights.&lt;/p&gt;

&lt;p&gt;How they do it: Apply statistical methods, advanced modeling, and clear communication.&lt;/p&gt;

&lt;p&gt;Let’s explore the skills that actually make a difference.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ideal Qualities for Data Analytics Professionals
&lt;/h2&gt;

&lt;p&gt;Succeeding in a data career takes more than technical skills. The best data professionals combine analytical thinking with strong communication, attention to context, and a mindset focused on impact. &lt;/p&gt;

&lt;p&gt;Below are five essential qualities every data professional should develop:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. &lt;strong&gt;Problem Solving&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Solving problems is at the heart of any data role. Whether you're handling incomplete data, fixing analysis issues, or communicating insights effectively—always aim to quantify the impact of the problems you solve.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; At a food delivery startup, customer cancellations spiked suddenly. A data analyst explored the pattern and found the majority were happening during lunchtime in one city. By correlating with weather data, they discovered rain-related delays were causing the issue. The company added a "weather delay warning" in the app, which led to a 15% drop in cancellations during peak hours.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Pro Tip: Tie your analysis to action. Always ask, “What decision will this insight improve?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  2. &lt;strong&gt;Clear Communication&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Professionals in data, business, and technology are expected to be fluent communicators.&lt;/p&gt;

&lt;p&gt;Insights are only valuable if they can be understood. Whether it’s writing a report, presenting findings, or building a dashboard, good communication bridges the gap between data and decision-makers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; After analyzing customer feedback, a data professional presented the key reasons for complaints to the product team using a visual dashboard. As a result, they focused on fixing the top three issues and reduced support tickets by &lt;strong&gt;40%&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Pro Tip: Never assume people “get it.” Make insights visual, actionable, and context-rich.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  3. &lt;strong&gt;Curiosity and a Willingness to Learn&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The best data professionals don’t just take questions at face value, they ask “why” and dig deeper. They constantly seek to learn new tools, methods, and context as the field evolves.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; A junior data analyst at a fashion brand noticed a popular product had unexpectedly low sales in a few regions. Rather than just flagging it, they looked into regional website behavior and discovered that the product images weren’t loading correctly due to a CDN issue. Fixing the error led to a 20% increase in regional conversions.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Pro Tip: Don't just be a responder, be an investigator.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  4. &lt;strong&gt;Understanding of the Business Context&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Knowing what matters to your organization helps prioritize your work and make insights more useful. See beyond the data and understand how it connects to real-world decisions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; A retail analyst who understood inventory costs recommended promoting slow-moving products based on data. This not only cleared out storage space but also increased monthly revenue.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Pro Tip: Learn your org’s KPIs—and align your insights to them.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  5. &lt;strong&gt;Adaptability&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Projects change. Data is messy. Stakeholder questions evolve. Flexibility and comfort with uncertainty are key traits for success.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; A financial analyst was tasked with forecasting next quarter's revenue. Midway through, the company announced a merger. Instead of restarting from scratch, they pivoted their model to include historical performance of similar mergers in the industry delivering a revised forecast on time, which helped shape early integration planning.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Pro Tip: See change not as a setback, but a signal to innovate.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Ethics, Privacy, and Bias: Core Responsibilities
&lt;/h2&gt;

&lt;p&gt;Data ethics refers to well-founded standards of right and wrong that dictate how data is collected, shared, and used.&lt;/p&gt;

&lt;h3&gt;
  
  
  Personally Identifiable Information (PII)
&lt;/h3&gt;

&lt;p&gt;Any data gathered from individuals or consumers is referred to as &lt;strong&gt;PII&lt;/strong&gt;—information that can identify someone either directly or indirectly. This includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Telephone numbers
&lt;/li&gt;
&lt;li&gt;Names
&lt;/li&gt;
&lt;li&gt;Social security numbers
&lt;/li&gt;
&lt;li&gt;IP addresses
&lt;/li&gt;
&lt;li&gt;Medical records
&lt;/li&gt;
&lt;li&gt;Email addresses
&lt;/li&gt;
&lt;li&gt;Account numbers
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because PII is often linked to medical, financial, or employment data, it must be managed with great care.&lt;/p&gt;

&lt;h3&gt;
  
  
  Privacy Matters
&lt;/h3&gt;

&lt;p&gt;Data privacy focuses on the &lt;strong&gt;access, use, and collection&lt;/strong&gt; of personal data. Key strategies to ensure privacy include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Access controls&lt;/strong&gt;: Ensuring only authorized personnel access sensitive data
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data anonymization&lt;/strong&gt;: Masking, hashing, or replacing personal information using fixed-length codes or altered values
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Imagine a world where we all had access to each other’s personal data. That would compromise privacy and safety. &lt;em&gt;Data anonymization&lt;/em&gt; helps protect individuals and preserve trust.&lt;/p&gt;

&lt;h3&gt;
  
  
  Avoid Creating or Reinforcing Bias
&lt;/h3&gt;

&lt;p&gt;Bias in data is often unintentional but can lead to harmful outcomes. Keep in mind:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data is gathered by humans and is affected by their backgrounds, beliefs, and experiences
&lt;/li&gt;
&lt;li&gt;Datasets may not represent the full population
&lt;/li&gt;
&lt;li&gt;Insights must be questioned before decisions are made
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Being aware of bias is key to building inclusive, accurate, and ethical data solutions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Know the Industry Standards
&lt;/h3&gt;

&lt;p&gt;Each industry has its own standards for data handling and analysis:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Transportation&lt;/strong&gt;: Focus on real-time data and route optimization
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Healthcare&lt;/strong&gt;: Prioritize accuracy, privacy, and patient outcomes
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Finance&lt;/strong&gt;: Emphasize security, compliance, and risk mitigation
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Understanding these nuances ensures your insights are practical and impactful.&lt;/p&gt;

&lt;h2&gt;
  
  
  Current and Future Tools
&lt;/h2&gt;

&lt;p&gt;A well-rounded data career is built on both foundational and emerging tools. Here’s a landscape snapshot:&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%2Fzf75cgoqxjppy1msik0e.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%2Fzf75cgoqxjppy1msik0e.png" alt="Tool Landscape" width="786" height="885"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Whether it’s SQL for querying, Python for modeling, or Tableau for storytelling- tools evolve, but your ability to learn remains your greatest asset.&lt;/p&gt;

&lt;h2&gt;
  
  
  How AI Fits Into a Data Career
&lt;/h2&gt;

&lt;p&gt;AI is becoming a powerful asset in the data professional’s toolkit, enhancing efficiency, insight generation, and automation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In Finance&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Analyze transactions to detect fraud
&lt;/li&gt;
&lt;li&gt;Identify investment risks and opportunities
&lt;/li&gt;
&lt;li&gt;Generate market insights and recommendations
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;In Retail&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Recommend products based on purchase history
&lt;/li&gt;
&lt;li&gt;Personalize the shopping experience
&lt;/li&gt;
&lt;li&gt;Forecast demand to optimize inventory and reduce costs
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  AI's Limitations
&lt;/h3&gt;

&lt;p&gt;AI is a tool; not a replacement for human judgment. Here’s why:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Lacks context&lt;/strong&gt;: AI makes decisions based on patterns in data; humans bring intuition and domain experience
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Struggles with ambiguity&lt;/strong&gt;: AI excels with well-defined problems, not complex, open-ended ones
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Can't communicate nuance&lt;/strong&gt;: AI can generate reports, but humans explain, persuade, and adapt communication to the audience
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Not creative&lt;/strong&gt;: Humans can imagine novel solutions and ask better questions, AI cannot
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Always &lt;strong&gt;verify AI output&lt;/strong&gt; and use it as an assistant, not a decision-maker.&lt;/p&gt;

&lt;h2&gt;
  
  
  Showcasing Your Work: Build a Public Portfolio
&lt;/h2&gt;

&lt;p&gt;Great work speaks for itself, but only if people can see it. A strong portfolio proves your skills and builds credibility.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. &lt;strong&gt;Tableau Dashboards&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Create interactive dashboards and share your work visually.&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%2Fuznqjerrwtbtoc57u9kd.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%2Fuznqjerrwtbtoc57u9kd.png" alt="Tableau" width="800" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. &lt;strong&gt;Kaggle Notebooks&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;For technical deep-dives or competitions, Kaggle is a great place to share and grow.&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%2Fmpspstxx0ifvclvg9hy4.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%2Fmpspstxx0ifvclvg9hy4.png" alt="Kaggle" width="800" height="422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. &lt;strong&gt;GitHub Repositories&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Use GitHub to publish your code, collaborate, and track your work over time.&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%2F58gl26so143wnzh4hkjf.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%2F58gl26so143wnzh4hkjf.png" alt="GitHub" width="800" height="415"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  4. &lt;strong&gt;Blogs&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Blog posts demonstrate not just technical know-how, but communication, storytelling, and critical thinking.&lt;/p&gt;

&lt;p&gt;A strong blog shows you're not only a good analyst, but a clear thinker and communicator.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts:
&lt;/h2&gt;

&lt;p&gt;Creating great work is important. But &lt;strong&gt;sharing&lt;/strong&gt; it is what builds visibility and opportunity. &lt;br&gt;
Whether through dashboards, notebooks, GitHub, or writing, your portfolio is your professional proof.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Your next opportunity might just come from someone stumbling across your dashboard, notebook, or blog post.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>datascience</category>
      <category>dataengineering</category>
      <category>career</category>
      <category>sql</category>
    </item>
  </channel>
</rss>
