Overview
List the orders placed in March: filter ISO dates as text, and avoid the BETWEEN trap that drops everything after midnight on the last day.
- ISO dates compare as text
- BETWEEN includes both ends
- >= start AND < next day
Short Course
Dates stored as ISO text ('2024-03-31 18:20') sort and compare correctly.
Trap: BETWEEN includes both ends, so BETWEEN '2024-03-01' AND '2024-03-31'
misses everything after midnight on the 31st. Use >= the start and < the
day after.
WHERE created_at >= '2024-03-01'
AND created_at < '2024-04-01' -- all of March
Task
Return the id of every order placed in March 2024, ordered by id. In the
database below, the order at 2024-03-31 18:20 counts.
Database
Sample data from the first test. The other tests use different rows, so write a query, not a list of answers.
| idINTEGER | created_atTEXT | totalREAL |
|---|---|---|
| 1 | 2024-02-29 23:59 | 10.0 |
| 2 | 2024-03-01 00:00 | 20.0 |
| 3 | 2024-03-15 12:30 | 5.0 |
| 4 | 2024-03-31 18:20 | 40.0 |
| 5 | 2024-04-01 00:00 | 8.0 |
Test Suites
Pending
Next
Output