Average friends by country

MediumMetaunion alltwo-way pairsleft join· 20 XP

Meta's growth team compares how connected users are in different countries. Friendships are stored once per pair, with the smaller id in user_id.

For each country, show the number of users and their average number of friends. Users with no friends count as 0.

Expected output

  • avg_friends rounded to 2 decimals; any row order

Example of the shape (made-up values):

country users avg_friends
Canada 20 7.85

Hints, the later steps and the answer come with Pro.

Write your query here. Ctrl + Enter submits.