Skip to content
ML Academy

SQL and Python

Interview question

  • midlevel
  • 12 minsuggested time
  • 2Data analyst, Data scientist

Given bookings(customer_id, booked_on) with several rows per customer, write a monthly cohort retention table: cohort = month of a customer's first booking, columns = months since the first booking, value = share of the cohort that booked again in that month. What are the traps?

Tests: Cohort analysis in SQL: first-event cohort, distinct counting, month offsets, denominators and incomplete months.

Sign in to practise: answers are saved before model answers are shown.