Skip to main content

Find Campaign Purchases

Medium

You are given 3 tables, campaign, user and transaction with the following columns

campaign table:

upsell_campaign_iddate_startdate_end
integertimestamptimestamp

user table:

user_idnameis_eligible_for_upsell_campaign
integerstringinteger

transaction table

transaction_iduser_idproduct_idtransaction_datequantity
integerintegerintegertimestampinteger

Write a SQL query that lists out the number of users for each campaign who were eligible for an upsell and purchased something.