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
Top Channels by Conversion Rate
00:00
5 left

Top Channels by Conversion Rate

MediumSQL · PostgreSQL

Problem

Rocket's Marketing Analytics team wants to evaluate acquisition performance for the Rocket App. Write a PostgreSQL query that identifies the top three marketing channels by monthly conversion rate.

Requirements

  1. Derive the month from each session's session_at timestamp.
  2. Calculate conversion rate as distinct converted sessions divided by distinct sessions, multiplied by 100.
  3. Prevent multiple conversion events for one session from inflating the conversion count.
  4. Rank channels independently within each month using ROW_NUMBER(), ordering by conversion rate descending, then session volume descending, then channel name ascending.
  5. Return only the top three channels for each month from January through March 2025.

Schema

channels
ColumnTypeDescription
channel_idPKINTMarketing channel identifier
channel_nameVARCHAR(100)Marketing channel name
campaigns
ColumnTypeDescription
campaign_idPKINTCampaign identifier
channel_idINTChannel associated with the campaign
campaign_nameVARCHAR(150)Campaign name
sessions
ColumnTypeDescription
session_idPKBIGINTRocket App visitor session identifier
campaign_idINTAttributed campaign identifier
session_atTIMESTAMPTZSession start timestamp
conversions
ColumnTypeDescription
conversion_idPKBIGINTConversion event identifier
session_idBIGINTSession that generated the conversion
converted_atTIMESTAMPTZConversion event timestamp
conversion_typeVARCHAR(50)Type of conversion event
Tableschannelscampaignssessionsconversions
Interviewer

Your question is Top Channels by Conversion Rate. Start with the requirements and the four 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.