Skip to main content

E-commerce: Earliest Order by Customer

EasyPremium

Amazon is a large e-commerce platform where customers can order various items ranging from electronics to clothing.

You're provided with two tables, orders and items, with the following columns:

order_idcustomer_idorder_dateitem_idorder_quantity
integerintegerdateintegerinteger
item_iditem_category
integerstring

Write a SQL query to get the earliest order_id for each customer for each date they placed an order (they can place multiple orders per day). Your output should have the following columns: customer_id, order_date, earliest_order_id. Order in ascending order date. Within the same date, order by ascending customer ID.

This question is part of a 5-part e-commerce question series. The other lessons in the series are linked below: