Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Unify Campaign Performance Sources

MediumSQL · PostgreSQL00:00
I
Practice interviewer
Your interviewer
In session
I
Interviewer

Welcome to the SQL screen.

The question is on your right: Unify Campaign Performance Sources. Read through the requirements and the four tables first.

Run and submit your code as often as you need. You also have five interviewer messages this session - want to talk through your approach, or are you ready to start coding?

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