Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Unify Campaign Performance Sources

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Unify Campaign Performance Sources. Start with the requirements and the four tables on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

You are asked to build a unified monthly campaign report by combining lead data from Salesforce, email engagement from Marketo, and web sessions from Google Analytics. Write a PostgreSQL query that returns one row per campaign for January 2024, showing the campaign name, total leads created, number of MQLs, total email sends, total email clicks, total web sessions, and a derived campaign_status that is Healthy when the campaign has at least 2 MQLs and a click-through rate of at least 10%; otherwise mark it Needs Review. Include campaigns even if they are missing data from one of the sources.

Schema

campaigns
ColumnTypeDescription
campaign_idPKINTUnique campaign identifier
campaign_nameVARCHAR(100)Campaign name
salesforce_leads
ColumnTypeDescription
lead_idPKINTUnique lead identifier
campaign_idINTAssociated campaign identifier
created_atDATELead creation date
lead_statusVARCHAR(20)Lead lifecycle status
marketo_email_stats
ColumnTypeDescription
stat_idPKINTUnique email stat record identifier
campaign_idINTAssociated campaign identifier
activity_dateDATEEmail activity date
sendsINTEmail sends for the record
clicksINTEmail clicks for the record
ga_campaign_sessions
ColumnTypeDescription
session_idPKINTUnique session record identifier
campaign_idINTAssociated campaign identifier
session_dateDATEWeb session date
sessionsINTNumber of sessions
Tablescampaignssalesforce_leadsmarketo_email_statsga_campaign_sessions
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results