🤓 Is SQL Broken?

Hello fellow data cruncher!

The Query here 👋

Here’s what we have for you today:

  • A must watch YouTube video ⏯️

  • A dataset for your next project 👨‍💻

  • New data jobs to apply to 💼

  • Some memes I love 🤣

def content_spotlight(🔦):

Have you ever thought SQL might be broken when it gave you a different output than you expected?

In this week’s video, I show you how this happened to me.

I’ll walk you through a common SQL mistake you might not even realize you’re making, why it happens, and how to fix it.

Enjoy! 😊

select * from data-jobs

remote, data jobs

Open to exploring new job opportunities?

We cultivate the best data analyst jobs from around the internet to make your search easier.

Check out this week’s featured jobs here.

  1. Data Analyst Intern @ Master Mover — $unlisted

  2. Data Analyst @ Unreal Gigs — $100-130k per year

  3. Senior BI Developer @ Jacuzzi Group — $140k per year

Thank you to our sponsors who keep this newsletter free to the reader:

How do you stay up-to-date with the insane pace of AI? Join The Rundown – the world’s fastest-growing AI newsletter with over 500,000+ readers learning how to become more productive using AI every morning.

1. Our team spends all day researching and talking with industry experts.

2. We send you updates on the latest AI news and how to apply it in 5 minutes a day.

3. You learn how to become 2x more productive by leveraging AI.

dataset_of_the_week (📊):

This week we’ve got a dataset for you — the Olist (largest department store in Brazilian marketplaces) E-commerce Dataset!

This dataset is perfect for a portfolio project AND for obtaining experience:

  • Analyzing real-world, sales data

  • Practicing SQL JOINS (there are 9 CSVs you’ll need to JOIN together)

Upload these CSVs into your database of choice and write SQL to bring your tables together.

Here are some questions to get your analysis started:

  • How often is the average order value for a second purchase, larger than the first purchase?

  • What is the average order value by city?

  • What’s the total value of orders that haven’t been delivered?

class SQLMiniLesson:

An interesting use case for NULLIF in SQL

Kyle here 👋 — I received a comment on one of my SQL posts on Linkedin asking how to compare whether two columns in the same table have the same value.

There are a number of ways to achieve this, but today I will be discussing one good approach.

The NULLIF function.

NULLIF() is a conditional function in SQL, meaning it uses IF/THEN logic.

It that compares two expressions and returns NULL if they are equal.

Otherwise, it returns the first expression.

Imagine you have a users table with columns for email and backup_email. You want to ensure that the backup_email is not the same as the primary email for security reasons.

Here's how you could use NULLIF in this case:

In the results of this query, email_comparison will be NULL if the email and backup_email are the same.

This could be helpful to quickly identify any instances where the backup email is the same as the primary email, which could be a security concern.

In other words, any row where email_comparison is NULL is a row where the email and backup_email are identical.

This way, NULLIF can be used to compare columns and identify identical values, which can be useful in a variety of scenarios where identical values in different columns could be a problem.

Quick tips like this can really speed up your workflow as an analyst.

Happy SQL’ing!

import memes as 😂 

content & resources 🤓 

1. Youtube Channel: Click here for Videos on SQL and data analytics.

2. Become a Data Analyst Guide: Our full guide on what it takes to land a job as a data analyst.

3. Open Data Analyst Jobs: Find your next data job here!

4. Download our SQL Cheatsheet as a PDF and desktop wallpaper here.

5. LinkedIn: We create content on LinkedIn daily. You can follow Cody here and Kyle here.

That’s it for today.

Stay crunchin’ folks and see you next week!

— Kyle

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

What'd you think of today's newsletter?

Login or Subscribe to participate in polls.