Tools Borrowed Only in Spring
Problem
A community tool library tracks every time a tool is lent out.
Table: tool
+-------------+---------+
| Column Name | Type |
+-------------+---------+
| tool_id | int |
| tool_name | varchar |
| deposit | int |
+-------------+---------+
tool_id is the primary key. Each row names a tool and its deposit amount.
Table: loan
+-------------+------+
| Column Name | Type |
+-------------+------+
| clerk_id | int |
| tool_id | int |
| borrower_id | int |
| lent_on | date |
| nights | int |
| fee | int |
+-------------+------+
This table may contain duplicate rows. Each row records one loan of a tool. tool_id references the tool table.
Write a solution that reports the tools that were lent out only during spring 2022, meaning between 2022-03-01 and 2022-05-31 inclusive and on no other dates. Return the result in any order with columns tool_id and tool_name.
Tables
Example rows — the live problem includes the full dataset.
| tool_id | tool_name | deposit |
|---|---|---|
| 1 | Drill | 1000 |
| 2 | Ladder | 800 |
| 3 | Mower | 1400 |
| clerk_id | tool_id | borrower_id | lent_on | nights | fee |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 2022-03-21 | 2 | 2000 |
| 1 | 2 | 2 | 2022-04-17 | 1 | 800 |
| 2 | 2 | 3 | 2022-08-02 | 1 | 800 |
Expected output
Your answer should return 1 row with the columns tool_id, tool_name.
Starter code (SQL)
SELECT *
FROM tool;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