Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Weekly Shopper Retention Rate

Medium
SQL & Data ManipulationWindow FunctionsDate FunctionsAggregationsAsked 3 times

Problem

ShopKart wants to measure how many shoppers return in the following week after making a purchase. Write a SQL query to calculate week-over-week shopper retention.

A shopper is considered retained in week W if they made at least one completed order in week W and also made at least one completed order in week W + 1.

Requirements

  1. Use only completed orders.
  2. Aggregate activity by shopper and calendar week using DATE_TRUNC('week', order_date).
  3. For each week, return:
    • the week start date
    • the number of active shoppers in that week
    • the number of those shoppers who returned the next week
    • the retention rate as retained_shoppers / active_shoppers, rounded to 4 decimals
  4. Exclude the final week in the dataset if there is no following week to evaluate retention against.
  5. Order results by week start date ascending.

Schema

shoppers
ColumnTypeDescription
shopper_idPKINTUnique shopper identifier
shopper_nameVARCHAR(100)Full name of the shopper
signup_dateDATEDate the shopper signed up
regionVARCHAR(50)Shopper region
orders
ColumnTypeDescription
order_idPKINTUnique order identifier
shopper_idINTShopper who placed the order
order_dateDATEDate the order was placed
order_statusVARCHAR(20)Order lifecycle status
order_totalNUMERIC(10,2)Total order amount
Practicing as: Product Growth Analyst interview at Splice

Hi, I'll play your Splice interviewer for the Product Growth Analyst role. Candidates describe these interviews as mostly positive and moderately difficult, so expect me to be friendly and conversational. Take your time with the question above and answer like we're in the room.

You are practicing as a guest. Sign up free to run your code against the sample data. Your draft stays right here.

Sign up freeI have an account
SELECT ...
FROM ...
JOIN ... ON ...
GROUP BY ...
HAVING ...
ORDER BY ... DESC;
Sign up to unlock solutions
Instacart Interview QuestionsInstacart Operations Manager Interview QuestionsPublicis Groupe Product Growth Analyst Interview Questions
Next questions
InstacartJanuary Shopper Retention RateEasyPublicis GroupeWeekly Active Purchaser Growth RateMediumSpliceWeekly Signup Cohort RetentionMedium