Skip to content

Sign-ups per campaign who placed a large order

EasyFreeJoinsRows with no matchGroup and aggregate8 min2 hidden datasets

The task

Marketing wants to know which campaigns bring in big spenders. A user is a big spender when they have at least one purchase with amount of 50.00 or more (50.00 itself counts).

For each campaign, count the sign-ups credited to it (signups.campaign_id) who are big spenders. Each user counts once, however many large purchases they made. Organic sign-ups, which have no campaign, are ignored.

Return campaign_id and big_spenders. Only campaigns with at least one big spender appear. Sort by big_spenders descending, then campaign_id ascending.

Expected output

campaign_idbig_spenders
  • Sorted by big_spenders descending, then campaign_id ascending.
  • 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