Skip to content

Sign-up to purchase conversion by campaign

MediumFull bankRatios and percentagesJoinsGroup and aggregate12 min2 hidden datasets

The task

The growth team judges each campaign by how many of its sign-ups ever bought something. A user is credited to a campaign through signups.campaign_id (organic sign-ups have no campaign and are not part of this). A user converted if they have at least one row in purchases, at any time.

Return one row for every campaign in campaigns:

  • campaign_name
  • conversion_pct, the converted users as a percentage (0 to 100) of the users credited to the campaign, rounded to 1 decimal place

A user who bought five times counts once. A campaign with no sign-ups has no conversion rate, so return NULL. Sort by conversion_pct descending with NULL last, then campaign_name ascending.

Expected output

campaign_nameconversion_pct
  • Sorted by conversion_pct descending, then campaign_name ascending.
  • Numbers rounded to 1 decimal place.
  • Checked on the sample and on 2 hidden datasets. How grading works

Tables Marketing team · click a name to insert it

campaigns10 rows in the sample

One row per campaign. Key: campaign_id.

intUnique id.
textName.
textsearch, social, video, email or affiliate.
dateFirst day live.
dateLast day live. NULL if still running.
numeric(10,2)Budget per day, USD.
ad_daily969 rows in the sample

One row per campaign per day it served ads. Days with no delivery have no row. Key: campaign_id, day.

intThe campaign.
dateThe day.
intTimes an ad was shown.
intClicks.
numeric(10,2)Money spent, USD.
signups2,108 rows in the sample

One row per new user. campaign_id is the campaign credited with the sign-up. Key: user_id.

intUnique id.
timestampWhen they signed up (UTC).
intCredited campaign. NULL for organic sign-ups.
textTwo-letter country code.
purchases2,294 rows in the sample

One row per paid order by a user. Key: purchase_id.

intUnique id.
intBuyer.
timestampWhen (UTC).
numeric(10,2)Order value, USD.

Related questions

Loading the editor and PostgreSQL