Busiest Reading Circles
Problem
A library runs several reading circles, and members can belong to more than one circle.
Table: circle_membership
+-------------+------+
| Column Name | Type |
+-------------+------+
| circle_id | int |
| member_id | int |
+-------------+------+
Each row records that the member with member_id belongs to the reading circle with circle_id. A pair (circle_id, member_id) is unique.
Table: reader
+-------------+---------+
| Column Name | Type |
+-------------+---------+
| member_id | int |
| full_name | varchar |
| books_read | int |
+-------------+---------+
member_id is the primary key. Each row describes one library member.
Write a solution that reports every reading circle that has the largest number of members. If several circles tie for the largest membership, report all of them. Return the result in any order.
Tables
Example rows — the live problem includes the full dataset.
| circle_id | member_id |
|---|---|
| 10 | 1 |
| 10 | 2 |
| 10 | 3 |
| member_id | full_name | books_read |
|---|---|---|
| 1 | Mara | 12 |
| 2 | Theo | 5 |
| 3 | Lin | 8 |
Expected output
Your answer should return 1 row with the columns circle_id.
Starter code (SQL)
SELECT *
FROM circle_membership;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock