SQL · Level 1 Filtering

SQL Date Ranges and BETWEEN

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

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

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.

Sample data from the first test. The other tests use different rows, so write a query, not a list of answers.

orders 5 rows
idINTEGERcreated_atTEXTtotalREAL
12024-02-29 23:5910.0
22024-03-01 00:0020.0
32024-03-15 12:305.0
42024-03-31 18:2040.0
52024-04-01 00:008.0
solution.sql
Test Suites Pending
Output