Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Top Marketing Channel by Revenue

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

Your question is Top Marketing Channel by Revenue. Start with the requirements and the three 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

Groupon marketing wants to identify which acquisition channel generated the most recognized revenue from attributed orders. Write a PostgreSQL query using Groupon campaign attribution data.

Requirements

  1. Join marketing channels, campaigns, and orders using their key relationships.
  2. Include only completed orders placed during January 2025, from January 1 through January 31.
  3. Aggregate gross revenue by marketing channel and return the top-performing channel or channels, including ties.
  4. Return channel_name and total_revenue, ordered by revenue descending and channel name ascending.

Schema

marketing_channels
ColumnTypeDescription
channel_idPKINTMarketing channel identifier
channel_nameVARCHAR(80)Groupon marketing channel name
channel_typeVARCHAR(40)Channel classification
campaigns
ColumnTypeDescription
campaign_idPKINTCampaign identifier
channel_idINTReferenced marketing channel
campaign_nameVARCHAR(120)Groupon campaign name
launched_atDATECampaign launch date
orders
ColumnTypeDescription
order_idPKINTOrder identifier
campaign_idINTAttributed campaign
order_dateDATEDate the order was placed
order_statusVARCHAR(20)Order processing status
gross_revenueDECIMAL(12,2)Recognized gross order revenue
Tablesmarketing_channelscampaignsorders
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results