BETWEEN: Filter Orders Within a Date Range

Basics
BasicsBETWEENDatesGoogleAmazonMeta

Table

  • orders(order_id INT, order_date VARCHAR)

Task

From orders(order_id, order_date) (ISO 'YYYY-MM-DD' strings), return order_id, order_date for orders placed in calendar year 2025 ('2025-01-01' through '2025-12-31' inclusive), ordered by order_id ASC.

Why It Matters: BETWEEN simplifies inclusive date-window filtering for monthly, quarterly, and campaign-period analytics.

Output columns: order_id, order_date

Example

Input — orders

order_idorder_date
12024-12-31
22025-01-01
32025-06-15
42025-12-31
52026-01-01

Expected Output

order_idorder_date
22025-01-01
32025-06-15
42025-12-31

Explanation: Keeps all orders whose date falls inclusively within the start and end bounds.

Requirements

  • Exact output columns: order_id, order_date
  • Row order: Exact ORDER BY order is checked by the grader.
  • Query type: Write a single read-only Standard SQL SELECT (or WITH ... SELECT) query.

Constraints & Evaluation Criteria

  • Return `order_id, order_date` ordered by `order_id ASC`.

Hints

SQL
Loading Code Editor...
+1 Hidden Submit Case
Input / Scenario
orders (5 rows)
Expected Output / Criteria
3 row(s): (2, 2025-01-01); (3, 2025-06-15); (4, 2025-12-31)