Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Weekly Active Purchaser Growth Rate

Medium
SQL & Data ManipulationDate FunctionsRunning TotalsAggregationsAsked 3 times

Problem

ShopWave wants to track how its active purchaser base changes week over week. Write a PostgreSQL query to calculate the weekly count of active purchasers and the week-over-week growth rate.

An active purchaser is a user who has at least one completed transaction in a given calendar week. Use the transaction date to assign each purchase to a week.

Requirements

  1. Count distinct purchasers per week using only transactions with status = 'completed'.
  2. Return one row per week, even if there are zero active purchasers that week.
  3. Calculate the prior week's active purchaser count.
  4. Compute week-over-week growth rate as: ((current_week_active_purchasers - previous_week_active_purchasers) / previous_week_active_purchasers) * 100 Return NULL when the previous week is 0 or missing.
  5. Order the output by week start date ascending.

Table Definitions

transactions

columntypedescription
transaction_idINTUnique transaction ID
user_idINTPurchasing user
transaction_dateDATEDate of the transaction
amountDECIMAL(10,2)Transaction amount
statusVARCHAR(20)Transaction status
store_idINTStore where the purchase happened

users

columntypedescription
user_idINTUnique user ID
user_nameVARCHAR(100)User name
signup_dateDATEUser signup date
countryVARCHAR(50)User country

Schema

transactions
ColumnTypeDescription
transaction_idPKINTUnique transaction identifier
user_idINTUser who made the transaction
transaction_dateDATEDate the transaction occurred
amountDECIMAL(10,2)Transaction amount
statusVARCHAR(20)Transaction processing status
store_idINTStore identifier
users
ColumnTypeDescription
user_idPKINTUnique user identifier
user_nameVARCHAR(100)User full name
signup_dateDATEDate the user signed up
countryVARCHAR(50)User country

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
Publicis Groupe Product Growth Analyst Interview Questions
Next questions
SpliceWeekly Shopper Retention RateMediumHelloFreshCompare Weekly User Activity TrendsMediumUber FreightMeasure Week-Over-Week Metric ChangesMedium
PostgreSQL