Your question is Rank Customer Segments by Revenue. Start with the requirements and the three 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 are given signup, account, and payment data from a B2B SaaS product. Write a SQL query to identify the highest-performing customer segments based on both revenue and signup-to-paid conversion. Treat a customer as converted if they have at least one successful payment within 30 days of signup. Return each segment's total customers, converted customers, conversion rate, total revenue from successful payments, and a rank ordered by highest revenue.
Use the segmentation dimensions already stored on the customer record, and only include segments with at least 2 customers.
| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| company_name | VARCHAR(100) | Customer company name |
| company_size_segment | VARCHAR(20) | Segment based on employee count |
| region | VARCHAR(20) | Customer geographic region |
| signup_date | DATE | Date the customer signed up |
| Column | Type | Description |
|---|---|---|
| account_idPK | INT | Unique billing account identifier |
| customer_id | INT | Customer associated with the account |
| plan_name | VARCHAR(30) | Subscribed Rippling plan |
| account_status | VARCHAR(20) | Current billing account status |
| Column | Type | Description |
|---|---|---|
| payment_idPK | INT | Unique payment identifier |
| account_id | INT | Billing account tied to the payment |
| payment_date | DATE | Date the payment was processed |
| amount_usd | DECIMAL(10,2) | Payment amount in USD |
| payment_status | VARCHAR(20) | Payment outcome |