Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL: Weekly Activation Rates

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

Your question is SQL: Weekly Activation Rates. 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

Write a SQL query to calculate weekly activation rates by acquisition channel and cohort for Spring Health. Use the members table and the weekly_calendar table. Treat a member as activated when activation_at falls within the reporting week, and label missing acquisition channels as Unknown.

Output

  1. One row per acquisition channel, signup cohort week, and reporting week through 2024-01-29.
  2. Columns: acquisition_channel, cohort_week, week_start, cohort_members, activated_members, and activation_rate.
  3. Include zero-activation weeks and sort by acquisition channel, cohort week, then week start.

Schema

members
ColumnTypeDescription
member_idPKINTUnique Spring Health member identifier
signup_atTIMESTAMPTimestamp when the member signed up
acquisition_channelVARCHAR(50)Marketing channel attributed to the signup
activation_atTIMESTAMPTimestamp when the member completed activation
weekly_calendar
ColumnTypeDescription
week_startPKDATEMonday starting the reporting week
week_endDATESunday ending the reporting week
Tablesmembersweekly_calendar
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results