Orders Placed in March 2026
Mediumsql
Write a query returning id, customer_name, order_date for every order placed in March 2026 (the 1st through the 31st, inclusive), ordered by id. (This case may legitimately return zero rows if no order falls in that month.)
sqlCREATE TABLE orders ( id INTEGER PRIMARY KEY, customer_name TEXT NOT NULL, amount INTEGER NOT NULL, order_date DATE NOT NULL );
Sample data:
sqlINSERT INTO orders (id, customer_name, amount, order_date) VALUES (1, 'Asha', 500, '2026-03-05'), (2, 'Rohan', 300, '2026-03-20'), (3, 'Neha', 700, '2026-04-02'), (4, 'Asha', 200, '2026-03-28');
Example 1
Input
(none)
Output
id customer_name order_date 1 Asha 2026-03-05 2 Rohan 2026-03-20 4 Asha 2026-03-28
A half-open range (>= start of month AND < start of next month) correctly and safely includes every timestamp in the month. Reference: SELECT id, customer_name, order_date FROM orders WHERE order_date >= '2026-03-01' AND order_date < '2026-04-01' ORDER BY id;