Annual Pass Available: Save up to 70%

The Cleanest Way to Get Interview-Ready in SQL, Python, and R

Structured practice, realistic datasets, and focused execution loops to help you perform with clarity in technical interviews.

230+

Interview-style coding questions

23+

Company-focused question sets

4

Practice engines: Postgres, MySQL, Python, R

March 2026 Leaderboard

User Score
#1 Ranked user: Blake
Blake Gold
115 pts
#2 Ranked user: Sydney
Sydney Silver
66 pts
#3 Ranked user: Greg
Greg Bronze
60 pts
#4 Ranked user: Deeptarka
Deeptarka
56 pts
#5 Ranked user: 421
421
55 pts
#6 Ranked user: Juan Andrés
Juan Andrés
50 pts
#7 Ranked user: shweta
shweta
47 pts
#8 Ranked user: Michaela
Michaela
42 pts
#9 Ranked user: Marieke
Marieke
38 pts
#10 Ranked user: Margareta
Margareta
38 pts

Anonymous Playground

Try a Real Question Before You Sign Up

Run SQL, Python, or R directly on this page. You can practice this sample without logging in.

Question 97

Social influencer

  • Write a query to return the user's id with the most friends.
  • Hint:We can assume there is one and only one person with the most friends, there is no tie.
  • A request can be accepted multiple times.

Table: accepted_request

Log when a friend request is accepted

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

Sample results

id
--------------
1000020

Official solution

POSTGRES
SELECT user_id_1 AS user_id
FROM (
	SELECT sender_id AS user_id_1, recipient_id user_id_2
	FROM accepted_request
	UNION 
	SELECT recipient_id AS user_id_1, sender_id user_id_2
	FROM accepted_request
) X
GROUP BY 1
ORDER BY COUNT(DISTINCT user_id_2) DESC
LIMIT 1;
Explanation

This query selects a user (aliasing it as "user_id") who has the most distinct accepted requests with other users.

To do this, it starts by creating a subquery that combines the sender and recipient IDs from the "accepted_request" table. It does this twice, once for each direction of the request (sender to recipient and recipient to sender). This is done using the UNION operator.

The resulting table is then grouped by the "user_id_1" column (which contains the user ID from the first column of the subquery). It counts the distinct "user_id_2" values (which contains the user ID from the second column of the subquery) for each "user_id_1". The results are then sorted in descending order based on the count of distinct "user_id_2" values.

Finally, the query selects only the first row (using LIMIT 1), which will be the user with the most distinct accepted requests with other users.

Expected results

Expected results appear after you submit.

Learners on SQLPad target interviews at

Loading testimonials...

Value Calculator

Estimate Your ROI with SQLPad

Enter your current salary and compare potential compensation upside against your SQLPad plan investment.

Summary

SQLPad starts at only $79/mo

Estimated annual upside

$0/year

Estimated ROI

0%

This salary estimate is based on publicly available compensation data for data scientists at top U.S. tech firms. Outcomes vary by interview performance, location, and hiring urgency.

Data engineers and machine learning engineers often earn more, so ROI can be higher for engineering-focused roles.

Loading FAQ...

Ready to Begin

Practice Daily. Interview Better.

Use SQLPad consistently and turn interview prep into a structured system instead of a guessing game.