Monthly Long Call Growth Rate
Beginner Mode
Objective
You are given a table of phone call records. Each row represents a single call with details about the caller, receiver, date, and duration in seconds.
Table Schema:
The phone_calls table:
| Column | Type | Description |
|---|---|---|
| caller_id | integer | ID of the person who made the call |
| receiver_id | integer | ID of the person who received the call |
| call_date | date | Date of the call |
| duration_secs | integer | Duration of the call in seconds |
Task Requirements:
- Filter for calls that last more than 5 minutes (300 seconds)
- Count the number of qualifying calls per month
- Calculate the month-over-month growth rate as a percentage
- Round the growth percentage to 1 decimal place
- The first month should show
NULLfor the growth rate since there is no previous month - Order the results by year and month in ascending order
Output columns: year, month, growth_pct
Examples
Example 1:
Output:
Input:
| phone_calls | |||
|---|---|---|---|
| call_date | caller_id | duration_secs | receiver_id |
| 2025-01-05 | 1 | 350 | 2 |
| 2025-01-10 | 1 | 200 | 3 |
| 2025-01-15 | 2 | 400 | 1 |
| 2025-01-20 | 3 | 500 | 1 |
| 2025-02-03 | 1 | 600 | 2 |
| 2025-02-08 | 2 | 310 | 3 |
| 2025-02-12 | 3 | 450 | 1 |
| 2025-02-15 | 3 | 100 | 2 |
| 2025-02-20 | 4 | 700 | 1 |
| 2025-02-25 | 4 | 320 | 2 |
| 2025-02-28 | 1 | 380 | 4 |
| 2025-02-10 | 2 | 500 | 4 |
| 2025-03-05 | 1 | 310 | 2 |
| 2025-03-10 | 2 | 250 | 1 |
| 2025-03-15 | 3 | 400 | 4 |
| 2025-03-20 | 4 | 350 | 1 |
| 2025-03-25 | 2 | 500 | 3 |
| 2025-03-28 | 1 | 600 | 3 |
| growth_pct | month | year |
|---|---|---|
| null | 1 | 2025 |
| 133.3 | 2 | 2025 |
| -28.6 | 3 | 2025 |
Code Environment
Sign in or try as guest to run your code.
Track
| Question | Difficulty | Company | Access |
|---|
Need more practice in this area? Explore more questions →
Twilio