0Pricing
Digital Marketing Academy · Lesson

Joining Marketing Tables

Sessions, users, orders.

Why Join?

Real questions span tables. Spend lives in campaigns, revenue in orders, traits in users. To compute ROAS or LTV by segment, you must combine them.

JOINs match rows from two tables on a shared key, like user_id or campaign_id.

SELECT o.order_id, u.country
FROM orders o
JOIN users u ON o.user_id = u.user_id;

INNER JOIN

An INNER JOIN returns only rows that match in both tables. Orders without a matching user, or users without orders, are dropped.

Use it when you only care about records that exist on both sides, such as purchasers.

SELECT u.user_id, u.country, SUM(o.revenue) AS revenue
FROM users u
JOIN orders o ON o.user_id = u.user_id
GROUP BY u.user_id, u.country;

All lessons in this course

  1. Why Marketers Learn SQL
  2. SELECT, WHERE, GROUP BY
  3. Joining Marketing Tables
  4. Cohort and Funnel Queries
← Back to Digital Marketing Academy