Stop 14 · SQL for Data AnalysisProjects · 1/2

Product Analytics Case Study

Part of the SQL Roadmap

In short

This project turns you from 'someone who writes queries' into 'someone who answers product questions'. You take one events dataset and tell the story of how a product is really doing.

A project using an events or orders dataset to answer product questions: active users, funnel conversion, retention by cohort and top features or products.

Wearing a stethoscope, the jaadu checks the pulse of a giant friendly shopping bag sitting on a clinic examination bed, with a clipboard tucked under its arm.

Think of it like this

A full body check-up

At a health check-up, the doctor doesn't run a hundred random tests. A few standard ones, like pulse, blood pressure, sugar and weight, tell most of the story, and anything unusual gets a closer look. A product has standard vitals too: active users, conversion, retention and top products. Your case study measures those, then digs into the odd one.

Watch it happen

The questions your case study answers

How healthy is the app?
Active users per month
Funnel conversion
Retention by cohort
Top products
Buyers and repeat buyers
Split by city

1/5Start with one big question a product manager would actually ask.

The big ideas

What you need to know

Questions first

Write the four or five business questions before any SQL. Every query should answer one of them.

Define every metric

Write down what 'active' and 'buyer' mean, like 'any event this month' and 'one or more purchases'.

Sanity-check numbers

Do the totals match a simple COUNT? Are there users with purchases but no app opens? Explain oddities.

End with a story

Findings plus recommendations, in plain words, with one chart per question. That's what gets read.

How it works

Running the case study

  1. 1

    Pick a dataset

    Use a public e-commerce or app events dataset, or generate a realistic one.

  2. 2

    Explore

    Learn the tables, the grain of each one and the date range.

  3. 3

    Measure

    Write one query per question: activity, funnel, retention, top products.

  4. 4

    Check

    Cross-check totals and investigate anything surprising.

  5. 5

    Present

    Write a README or short deck with findings and two or three recommendations.

See it in code

Walk through the code

sql
1-- Monthly active users, buyers and repeat buyers2WITH monthly AS (3  SELECT DATE_TRUNC('month', event_time)::date           AS month,4         user_id,5         COUNT(*) FILTER (WHERE event_name = 'purchase') AS purchases6  FROM events7  GROUP BY 1, 28)9SELECT month,10       COUNT(*)                                      AS active_users,11       COUNT(*) FILTER (WHERE purchases > 0)         AS buyers,12       ROUND(100.0 * COUNT(*) FILTER (WHERE purchases > 0)13             / COUNT(*), 1)                          AS buyer_pct,14       COUNT(*) FILTER (WHERE purchases >= 2)        AS repeat_buyers15FROM monthly16GROUP BY month17ORDER BY month;

1/5One row per user per month, with how many purchases they made that month.

PostgreSQL syntax. In MySQL, replace DATE_TRUNC with DATE_FORMAT(event_time, '%Y-%m-01') and each FILTER with SUM(CASE WHEN ... THEN 1 ELSE 0 END).

Save yourself the pain

Common mistakes

Oops

Writing twenty clever queries with no clear question behind them.

Do this instead

Start from four or five questions and cut any query that doesn't answer one.

Oops

Presenting raw tables of numbers as the result.

Do this instead

Lead with the finding in one sentence, then show the chart or table that proves it.

Your mission

Ship the case study

~120 min

Quick check

Why is the first CTE grouped by month and user_id before counting active users?

Go deeper

  1. 1Pick a public events dataset or the Google Analytics sample in BigQuery.
  2. 2Write the questions first, then one well-commented query per question.
  3. 3Finish with three recommendations backed by your numbers.

More projects at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge