AnalystPath

Library Entries Without a Checkout

SQLEasyJunior level~15 min

Problem

A public library records every member entry in `LibraryEntries` and every item borrowed in `Checkouts`. A single entry can result in zero, one, or many checkouts.

`LibraryEntries`:
- `entry_id` (int) — unique id of one entry into the library
- `member_id` (int) — member who entered

`Checkouts`:
- `checkout_id` (int) — unique id of one borrowed item
- `entry_id` (int) — the entry during which the item was borrowed
- `item_count` (int) — how many copies were taken

Find every member who entered the library but borrowed nothing during that entry, and how many such empty-handed entries each made. Rows may be in any order.

Tables

Example rows — the live problem includes the full dataset.

LibraryEntries
entry_idmember_id
123
29
430
Checkouts
checkout_identry_iditem_count
252
351
954

Expected output

Your answer should return 3 rows with the columns member_id, empty_entries.

Starter code (SQL)

SELECT *
FROM LibraryEntries;

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