Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Cohort Conversion Comparison

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

Your question is Cohort Conversion Comparison. 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

Business Context

Mirakl marketplace analytics needs to compare how effectively buyer cohorts convert after joining the marketplace.

Task

Write a PostgreSQL query that calculates and ranks buyer conversion rates by signup-month cohort for January through April 2025. A buyer is converted if they have at least one order with order_status = 'completed'.

Requirements

  1. Derive each buyer's cohort from the month of signup_date using PostgreSQL date functions.
  2. Include every eligible buyer in the cohort denominator, including buyers without orders or with only non-completed orders.
  3. Return cohort size, converted buyers, conversion rate as a percentage rounded to two decimals, and the cohort rank using a window function.
  4. Sort by conversion rate descending, then cohort month ascending.

Schema

marketplace_buyers
ColumnTypeDescription
buyer_idPKINTEGERUnique Mirakl marketplace buyer identifier
signup_dateDATEDate the buyer joined the marketplace
acquisition_channelVARCHAR(30)Channel that generated the buyer signup
marketplace_orders
ColumnTypeDescription
order_idPKINTEGERUnique marketplace order identifier
buyer_idINTEGERBuyer associated with the order
order_dateDATEDate the order was placed
order_statusVARCHAR(20)Order lifecycle status
Tablesmarketplace_buyersmarketplace_orders
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results