AnalystPath

Tools Borrowed Only in Spring

SQLEasyJunior level~15 min

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
tool_idtool_namedeposit
1Drill1000
2Ladder800
3Mower1400
loan
clerk_idtool_idborrower_idlent_onnightsfee
1112022-03-2122000
1222022-04-171800
2232022-08-021800

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

Related SQL questions