← Interview questions
Snapchat logo

Sending vs Opening Snaps

Snapchat·medium·SQL

Given tables for user activity and age groups, show what percentage of each age group's total time was spent sending snaps vs opening snaps. Exclude other activity types. Round to 2 decimal places.

Schema

activities
activity_idINTEGER
user_idINTEGER
typeVARCHAR
time_spentFLOAT
activity_dateDATETIME
type values: 'send', 'open', 'chat'
age_breakdown
user_idINTEGER
age_bucketVARCHAR
age_bucket values: '21-25', '26-30', '31-35', '36-40', '41-45', '46-50'

Target output

Target output
age_bucketsend_percopen_perc
21-2558.5741.43
26-3077.7822.22
Queryactivities, age_breakdown
Cmd+Enterto runLoading...
Output

Loading sample data...