Slack’s enterprise team wants to identify accounts at risk of churning. A high-risk account is defined as a company that has purchased "Pro" seats but is using less than 20% of them.
Write an SQL query to find these companies.
Rules:
- Only consider "Pro" plan subscriptions.
- Utilization Rate = (active_seats / purchased_seats) * 100.
- active_seats is the count of unique users from the CompanyUsers table with an active status.
- Output columns: company_id, company_name, purchased_seats, active_seats, utilization_rate.
- Round utilization_rate to 2 decimal places.
- Results must be returned in ascending order of utilization_rate.
Table Schema:
- Companies: company_id, company_name.
- Subscriptions: sub_id, company_id, plan_type (Pro, Basic), purchased_seats (INTEGER).
- CompanyUsers: user_id, company_id, status (active, inactive).