Search ⌘K
Google
Google

Foundations Track · Medium · 25 min

9822 Average Number Of Friends

SELECT AVG(t2.num_friends) as avg_num_friends_per_user FROM ( SELECT t1.user, COUNT(friend) as num_friends FROM ( SELECT user_id as user, friend_id as friend...

Foundations Track
Medium
25 min
aggregation

Company labels are directional practice context, not official interview guidance.

Timer 00:00
Back to practice

Objective

Practice aggregation through a Google-tagged business scenario.

Approach

Use this track to lock in clean query structure, basic filtering logic, and confidence with grouped output.

Company context

Company labels are directional practice context, not official interview guidance.

Prereq: query basics
Prereq: filtering

SELECT AVG(t2.num_friends) as avg_num_friends_per_user FROM ( SELECT t1.user, COUNT(friend) as num_friends FROM ( SELECT user_id as user, friend_id as friend FROM google_friends_network UNION SELECT friend_id as user, user_id as friend FROM google_friends_network ) t1 GROUP BY 1 ) t2;

Pro question
This is a Pro question

Upgrade to Pro to unlock this prompt, the SQL workspace, and all 254 problems.

Upgrade to Pro — unlock all 254 problems
Editor
SQL workspace

Run queries against the protected question data, then submit once the result shape looks right.

Sign in to run SQL

Create a free account or sign in before running queries against protected question data.