101
0/304
Loading content...
A telecom analytics pipeline records each phone interaction as a directed event from one user to another. Product teams need a pair-level rollup where direction is ignored so they can measure overall relationship intensity.
Table: calls
Task: For every distinct unordered user pair, return:
Business rules:
Output requirements:
Supported submission environments:
calls:
| from_id | to_id | duration |
|---------|-------|----------|
| 1 | 2 | 59 |
| 2 | 1 | 11 |
| 1 | 3 | 20 |
| 3 | 4 | 100 |
| 3 | 4 | 200 |
| 3 | 4 | 200 |
| 4 | 3 | 499 |[
{"person1":1,"person2":2,"call_count":2,"total_duration":70},
{"person1":1,"person2":3,"call_count":1,"total_duration":20},
{"person1":3,"person2":4,"call_count":4,"total_duration":999}
]Rows are normalized into unordered pairs. Calls between users 3 and 4 appear in both directions and multiple rows, so they aggregate to 4 calls and 999 total seconds.
calls:
| from_id | to_id | duration |
|---------|-------|----------|
| 10 | 20 | 30 |
| 20 | 10 | 45 |
| 10 | 20 | 25 |
| 30 | 10 | 8 |
| 10 | 30 | 12 |
| 30 | 40 | 50 |[
{"person1":10,"person2":20,"call_count":3,"total_duration":100},
{"person1":10,"person2":30,"call_count":2,"total_duration":20},
{"person1":30,"person2":40,"call_count":1,"total_duration":50}
]Pair (10,20) appears three times in mixed directions; all three rows contribute to one aggregate record.
calls:
| from_id | to_id | duration |
|---------|-------|----------|
| (no rows) |[]With no calls, there are no user pairs to report.
Constraints