Back to Practice
#0122

Signup to Purchase Funnel

MediumSQL25 min20 XP

Problem

Given events(user_id, event_name), return one row with signups and purchases counting distinct users for each event_name.

Why This Matters

Funnels are one of the most common product analytics SQL tasks.

Schema

events(user_id INTEGER, event_name TEXT)

Examples

Example 1
Inputusers with signup and purchase events
Outputsignups and purchases counts

Distinct user counts avoid double-counting repeated events.

Constraints

  • Return the requested value exactly.
  • Handle the stated edge cases.
  • Keep the solution readable.
CodeSQL
Visible browser tests run here when available.
Testcases1 visible / 3 hidden categories
Core example
Inputusers with signup and purchase events
Expectedsignups and purchases counts

Distinct user counts avoid double-counting repeated events.

Hidden Test Categories
repeat signupsno purchasesusers with purchase but no signup