Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Top Ad Campaigns by Conversion

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

Your question is Top Ad Campaigns by Conversion. Start with the requirements and the two 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

InMobi Product Analytics needs to compare campaign efficiency across the InMobi Exchange. Write a PostgreSQL query to identify the five campaigns with the highest conversion rate during January 2025.

Requirements

  1. Join campaign metadata with daily performance data.
  2. Aggregate January impressions, clicks, and conversions by campaign.
  3. Define conversion rate as conversions divided by clicks, expressed as a percentage. Treat NULL conversions as zero and exclude campaigns with zero total clicks.
  4. Return the top five campaigns, ordered by conversion rate descending and campaign ID ascending to break ties.

Schema

campaigns
ColumnTypeDescription
campaign_idPKINTUnique campaign identifier
campaign_nameVARCHAR(120)Campaign name
advertiserVARCHAR(100)Advertiser or agency name
campaign_daily_performance
ColumnTypeDescription
performance_idPKINTUnique daily performance record
campaign_idINTReferenced campaign identifier
performance_dateDATEReporting date
impressionsINTNumber of ad impressions
clicksINTNumber of ad clicks
conversionsINTNumber of attributed conversions
Tablescampaignscampaign_daily_performance
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results