sign up today

Ready to Go Pro with Maven Analytics

Ready to Go Pro with Maven Analytics

Sign up today an unlock full access to all data and AI learning content.

free email course

SQL with AI

Day 3

Basic

free email course

SQL with AI

Day 3

Basic

The Brief

Wow, I can't believe we're on Day 3 already! In case you forgot, it's still John at Maven Analytics here.

Yesterday you found that INNER JOINs silently hide unmatched rows, and that LEFT JOINs are how you surface what's missing. Today we build on that with a framework for approaching any multi-table query, then use it to run the analysis Sarah actually needs.

Three questions before you write a multi-table query

Most people jump straight to writing the JOIN. That's how you end up with queries that work technically but answer the wrong question.

Before touching the keyboard, answer these:

1. Which table is the anchor? The table your question is fundamentally about. If the question is "what are customers buying?", the anchor is customers. If it's "which products are selling to which segments?", the anchor is orders, because orders link products to customers.

2. Which other tables do I need, and why? List them and the reason each is needed. If you can't say in one sentence why a table is necessary, you probably don't need it.

3. What type of JOIN does each connection need? All rows from the left side even with no match → LEFT JOIN. Only rows where both sides match → INNER JOIN. (And RIGHT JOINs as I mentioned yesterday are only for the crazy!)

Write through these three questions before every multi-table query for the next two weeks. It feels slow at first. Then it becomes instinct.

Environment Setup

Environment Setup

exercise 1

Apply the framework to Sarah's real question

5 min

exercise 1

Apply the framework to Sarah's real question

5 min

exercise 2

Look at product-level profitability across segments

5 min

exercise 2

Look at product-level profitability across segments

5 min

exercise 3

The customer leaderboard

5 min

exercise 3

The customer leaderboard

5 min

Go Deeper

Go Deeper

Looking forward to Tomorrow

Looking forward to Tomorrow

© Maven Analytics, LLC | All Rights Reserved

© Maven Analytics, LLC | All Rights Reserved

© Maven Analytics, LLC | All Rights Reserved