You are working as a Data Engineer for an e-commerce platform. The operations team wants to analyze daily order activity to understand customer purchasing patterns. You are given a table called orders with the following structure: order_id (INTEGER): Unique identifier for each order customer_id (INTEGER): Identifier for the customer order_date (DATE): Date when the order was placed order_amount (NUMERIC): Total amount of the order Task: Write a SQL query to calculate the number of orders placed each day . Expected Output: order_date total_orders (count of orders per day) The result should be sorted by order_date in ascending order.
Table Setup (SQL Schema)
-- DDL: Create table
CREATE TABLE orders (
order_id INTEGER PRIMARY KEY,
customer_id INTEGER,
order_date DATE,
order_amount NUMERIC(10, 2)
);
-- DML: Insert sample data
INSERT INTO orders (order_id, customer_id, order_date, order_amount) VALUES
(1, 101, '2024-02-01', 120.00),
(2, 102, '2024-02-01', 200.00),
(3, 103, '2024-02-02', 150.00),
(4, 101, '2024-02-02', 80.00),
(5, 104, '2024-02-03', 300.00),
(6, 102, '2024-02-03', 50.00),
(7, 105, '2024-02-03', 220.00),
(8, 103, '2024-02-04', 175.00),
(9, 101, '2024-02-04', 90.00),
(10, 104, '2024-02-05', 400.00);