AnalystPath

Busiest Reading Circles

SQLEasyJunior level~15 min

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_membership
circle_idmember_id
101
102
103
reader
member_idfull_namebooks_read
1Mara12
2Theo5
3Lin8

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

Related SQL questions