Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
SQL Joins for Campaign and Transactions
00:00
5 left

SQL Joins for Campaign and Transactions

MediumSQL · PostgreSQL

Problem

Write a SQL query utilizing different types of JOINs to combine Seatgeek marketing campaign spend data with user transaction records.

Use the provided tables and return one row per campaign with spend. Include campaigns with no matching completed transactions, exclude spend rows whose campaign ID is not defined, and count only completed transactions.

Output

  1. Columns: campaign_id, campaign_name, total_spend, completed_transactions, completed_revenue
  2. One row per defined campaign with at least one spend record
  3. Order by campaign_id ascending

Schema

marketing_campaigns
ColumnTypeDescription
campaign_idPKVARCHAR(20)Unique Seatgeek marketing campaign identifier
campaign_nameVARCHAR(100)Campaign display name
channelVARCHAR(30)Primary marketing channel
campaign_spend
ColumnTypeDescription
spend_idPKINTUnique spend record identifier
campaign_idVARCHAR(20)Campaign associated with the spend record
spend_dateDATEDate the spend was recorded
spend_amountNUMERIC(12,2)Marketing spend amount
user_transactions
ColumnTypeDescription
transaction_idPKINTUnique user transaction identifier
user_idINTUser associated with the transaction
campaign_idVARCHAR(20)Campaign attributed to the transaction
transaction_dateDATEDate of the transaction
statusVARCHAR(20)Transaction lifecycle status
gross_amountNUMERIC(12,2)Gross transaction amount
Tablesmarketing_campaignscampaign_spenduser_transactions
Interviewer

Your question is SQL Joins for Campaign and Transactions. Start with the requirements and the three tables in the Question tab.

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.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.