Your question is Month-Over-Month Merchant Retention. 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.
Shopify wants to monitor whether active merchants continue using Shopify across consecutive months. Write a PostgreSQL query that calculates month-over-month retention for each month with a preceding month of activity.
status = 'active'.| Column | Type | Description |
|---|---|---|
| merchant_idPK | INT | Unique Shopify merchant identifier |
| shop_domain | VARCHAR(255) | Shopify shop domain |
| status | VARCHAR(20) | Merchant account status |
| created_at | DATE | Date the merchant account was created |
| Column | Type | Description |
|---|---|---|
| activity_idPK | INT | Unique activity record identifier |
| merchant_id | INT | Referenced merchant identifier |
| activity_type | VARCHAR(50) | Type of merchant activity |
| occurred_at | TIMESTAMP | Timestamp when the activity occurred |