International Call Percentage
Beginner Mode
Objective
Write a SQL query to calculate the percentage of phone calls that are international.
Table Schema:
- phone_calls
| Column | Type | Description |
|---|---|---|
| caller_id | INTEGER | ID of the caller |
| receiver_id | INTEGER | ID of the receiver |
- phone_info
| Column | Type | Description |
|---|---|---|
| caller_id | INTEGER | ID of the phone user |
| country_id | INTEGER | Country of the phone user |
Task Requirements:
- A call is international if the caller and receiver are in different countries
- Look up the country for both the caller and the receiver using the
phone_infotable - Calculate the percentage of international calls out of total calls
- Round the result to 1 decimal place
Output columns: international_pct
Examples
Example 1:
Output:
Input:
| phone_calls | |
|---|---|
| caller_id | receiver_id |
| 1 | 2 |
| 1 | 3 |
| 3 | 4 |
| 2 | 5 |
| 5 | 1 |
| 4 | 3 |
| 3 | 1 |
| phone_info | |
|---|---|
| caller_id | country_id |
| 1 | 1 |
| 2 | 1 |
| 3 | 2 |
| 4 | 2 |
| 5 | 3 |
| international_pct |
|---|
| 57.1 |
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