Write a query to identify users who have experienced a sudden drop in transaction frequency over the last 30 days compared to their historical average at Stripe.
Use April 2025 as the last 30-day period and January through March 2025 as the historical period. Consider only successful transactions. A user qualifies when their recent count is less than 50% of their historical average 30-day count and they have at least one historical transaction.
user_id, email, recent_transaction_count, historical_avg_30_day_count, and drop_ratiodrop_ratio ascending, then user_id ascending| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique Stripe user identifier |
| VARCHAR(255) | User email address |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| user_id | INT | User who initiated the transaction |
| transaction_date | DATE | Transaction processing date |
| status | VARCHAR(20) | Transaction outcome, such as succeeded or failed |
| amount | NUMERIC(12,2) | Transaction amount in USD |