Out past midnight
- O(1) · Trivial
- Free
- SQL
- filtering
- comparisons
Problem
The librarian wants to know which loans were out on New Year's Eve, the night of December 31, 2025, into January 1, 2026, so she can ask those members whether they really read over the holidays. She's only asking about loans that have already come back.
A book spent that night out if it was borrowed on December 31 or earlier and returned on January 1 or later. One that came back on the 31st itself slept on its shelf.
Show the member, the date the book was borrowed, and the date it was returned, in that order.
What it has to return
These rows, in any order
| member | borrowed | returned |
|---|---|---|
| Brian | 2025-12-20 | 2026-01-04 |
This is what comes out with the data in the practice database this challenge uses. The column names don’t count, so name yours however you like: what counts is how many there are and the order they come in. Besides this one, the challenge has hidden tests with other data that are revealed when you submit your solution.
You start with this
SQL
SELECT member, borrowed, returned
FROM loansIt opens in your browser, with the editor and the tests. It is free and you do not need an account to start.