98. Most popular user

easy facebook

  • ***************************************************************************************
  • *********************************************************************************************
  • *******************************************************************

Table: friend_request

Friend request table

  col_name    | col_type
--------------+--------------------------
 sender_id    | bigint
 recipient_id | bigint
 request_dt   | date

Sample results

id
--------------
1000027

Solution postgres

SELECT recipient_id
FROM friend_request
WHERE request_dt >= '2021-01-01'
AND request_dt < '2021-02-01'
GROUP BY recipient_id
ORDER BY COUNT(DISTINCT sender_id) DESC
LIMIT 1;
    

Explanation

This query retrieves the recipient_id from the friend_request table for the requests made in January 2021. It groups the recipient_id by the number of distinct sender_id, orders them in descending order, and only returns the top result. This means that it will return the recipient who received the most friend requests from unique senders in January 2021.

Expected results


More Facebook questions

ID Title Level FTPR
81 How many people searched on new year's day facebook easy
24%
82 The top search query on new year's day facebook easy
13%
83 Top search_query in US and UK on new year's day facebook medium
6%
84 Click through rate on new year's day facebook medium
9%
85 Top 4 queries based on click through rate on new year's day facebook hard
7%
96 Overall acceptance rate facebook easy
13%
97 Social influencer facebook easy
10%
99 Page recommendation facebook medium
13%
100 Advertiser ROI facebook medium
8%
172 Comments distribution facebook hard
13%
173 User Popularity Percentage facebook medium
11%
174 Closed accounts facebook easy
23%