Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Cohort Rolling Conversion Rate

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

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

GoDaddy wants to monitor conversion performance for customers who begin using products such as Websites and Domains. Write a PostgreSQL query that calculates a 7-day rolling conversion rate for each customer cohort and active event date.

Requirements

  1. Join customer cohort data with funnel events using user_id.
  2. Calculate daily distinct visitors and daily distinct converters for each cohort_date and event_date. A non-null converted_at indicates a conversion.
  3. Use window functions to calculate rolling 7-day visitors and converters within each cohort. The window must include the current date and the previous six calendar days, even when some dates have no activity.
  4. Return the rolling conversion rate, rounded to four decimal places, and order results by cohort and event date.

Only cohort dates with at least one funnel event are required in the output.

Schema

users
ColumnTypeDescription
user_idPKINTUnique customer identifier
cohort_dateDATEDate the customer entered the cohort
product_nameVARCHAR(100)GoDaddy product associated with the customer
funnel_events
ColumnTypeDescription
event_idPKINTUnique funnel event identifier
user_idINTCustomer who generated the event
event_dateDATEDate of funnel activity
converted_atTIMESTAMPConversion timestamp, or NULL when the event did not convert
Tablesusersfunnel_events
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results