101
0/304
Loading content...
A messaging analytics team wants to understand behavior differences across age cohorts.
Table: Activities
Table: Age
Task: For every age_bucket that has activity records, compute:
Formally, for each cohort:
Round both percentages to exactly 2 decimal places.
Output requirements:
Supported submission environments:
Activities:
| activity_id | user_id | activity_type | time_spent |
|-------------|---------|---------------|------------|
| 7274 | 123 | open | 4.50 |
| 2425 | 123 | send | 3.50 |
| 1413 | 456 | send | 5.67 |
| 2536 | 456 | open | 3.00 |
| 8564 | 456 | send | 8.24 |
| 5235 | 789 | send | 6.24 |
| 4251 | 123 | open | 1.25 |
| 1435 | 789 | open | 5.25 |
Age:
| user_id | age_bucket |
|---------|------------|
| 123 | 31-35 |
| 789 | 21-25 |
| 456 | 26-30 |[
{"age_bucket":"21-25","send_perc":54.31,"open_perc":45.69},
{"age_bucket":"26-30","send_perc":82.26,"open_perc":17.74},
{"age_bucket":"31-35","send_perc":37.84,"open_perc":62.16}
]Each cohort percentage is computed from its own total time, not from global totals.
Activities:
| activity_id | user_id | activity_type | time_spent |
|-------------|---------|---------------|------------|
| 1 | 10 | send | 2.00 |
| 2 | 10 | send | 3.00 |
| 3 | 11 | open | 5.00 |
| 4 | 11 | open | 5.00 |
Age:
| user_id | age_bucket |
|---------|------------|
| 10 | 21-25 |
| 11 | 26-30 |[
{"age_bucket":"21-25","send_perc":100.0,"open_perc":0.0},
{"age_bucket":"26-30","send_perc":0.0,"open_perc":100.0}
]A cohort can be fully dominated by one action type. The other percentage becomes 0.00.
Activities:
| activity_id | user_id | activity_type | time_spent |
|-------------|---------|---------------|------------|
| 91 | 501 | send | 0.01 |
| 92 | 501 | open | 0.02 |
| 93 | 502 | send | 0.02 |
| 94 | 502 | open | 0.01 |
Age:
| user_id | age_bucket |
|---------|------------|
| 501 | 31-35 |
| 502 | 31-35 |[
{"age_bucket":"31-35","send_perc":50.0,"open_perc":50.0}
]Very small durations are still valid; aggregate first, then compute percentages.
Constraints