Total Pages Read per Library Member
Problem
Tables: `members`, `loans`
**members**
| Column Name | Type |
|---|---|
| member_id | int |
| full_name | varchar |
`member_id` is the primary key.
**loans**
| Column Name | Type |
|---|---|
| loan_id | int |
| member_id | int |
| pages_read | int |
`loan_id` is the primary key. Each row records how many pages a member read from one borrowed book.
Report the total pages read by every member. A member with no loans must still appear with a total of 0. Output `member_id`, `full_name`, and the total aliased as `pages read`. Order by `member_id`.
Tables
Example rows — the live problem includes the full dataset.
| member_id | full_name |
|---|---|
| 3 | Priya Nair |
| 7 | Diego Alves |
| 12 | Hannah Berg |
| loan_id | member_id | pages_read |
|---|---|---|
| 1 | 3 | 120 |
| 2 | 3 | 80 |
| 3 | 7 | 300 |
Expected output
Your answer should return 4 rows with the columns member_id, full_name, pages read.
Starter code (SQL)
SELECT *
FROM members;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