# E-commerce SQL question: earliest order per customer and date

Aced (formerly Exponent) publishes a public search API over its indexed pages; the guide is at https://www.aced.io/agents/agent-access.

Source: https://www.aced.io/questions/3105/e-commerce-part-4
Source observed: 2026-11-04T23:18:05.085Z
Last checked: 2026-11-04T23:18:05.085+00:00
Indexed: 2026-11-07T02:25:59.766+00:00

---

# E-commerce (4 of 5)

We provide SQL interview practice through Aced, formerly Exponent. This **Easy** coding question asks you to query e-commerce order data. It is categorized under [Coding](https://www.aced.io/questions?type=coding) and [SQL](https://www.aced.io/questions?type=sql).

## Scenario

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

## Available tables

You are given an `orders` table with these columns:

| Column | Type |
|---|---|
| `order_id` | `integer` |
| `customer_id` | `integer` |
| `order_date` | `date` |
| `item_id` | `integer` |
| `order_quantity` | `integer` |

You are also given an `items` table:

| Column | Type |
|---|---|
| `item_id` | `integer` |
| `item_category` | `string` |

## Task

Write a SQL query that returns the earliest `order_id` for each customer on each date when that customer placed an order. A customer may place multiple orders on the same date.

Return exactly these columns:

- `customer_id`
- `order_date`
- `earliest_order_id`

Sort the results by ascending `order_date`. For rows on the same date, sort by ascending `customer_id`.

## Access and practice controls

Detailed company statistics require an [upgrade](https://www.aced.io/upgrade?src=questions). The question interface includes **Question**, **Solution**, and **Community** tabs; the community area currently has no contributed answers. You can [sign up to run code](https://www.aced.io/signup?src=lesson).

## Five-part e-commerce series

This question is part 4 of 5. The other lessons are:

1. [E-commerce: Units Ordered Yesterday](https://www.tryexponent.com/courses/sql-interviews/e-commerce-i) — 1 of 5
2. [E-commerce: Units Ordered Last Week](https://www.tryexponent.com/courses/sql-interviews/e-commerce-ii) — 2 of 5
3. [E-commerce: Total Orders by Category](https://www.tryexponent.com/courses/sql-interviews/e-commerce-iii) — 3 of 5
4. [E-commerce: Second Earliest Order](https://www.tryexponent.com/courses/sql-interviews/e-commerce-v) — 5 of 5

## Related questions

- [E-commerce (5 of 5)](https://www.aced.io/questions/3106/e-commerce-part-5)
- [E-commerce (1 of 5)](https://www.aced.io/questions/3102/e-commerce-part-1)
- [E-commerce (3 of 5)](https://www.aced.io/questions/3104/e-commerce-part-3)

The question is marked **Easy**. The interface also displays one interview coding report and the label “Reported last asked: 3 years ago.”

---

[Read this page’s summary](https://www.aced.io/agents/api/public/v1/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F3105%2Fe-commerce-part-4&trace=t_679ff9ab98f3)

## Ask a follow-up about this page

Need a more specific answer? Ask the exact question you have. It returns a fresh, cited answer from Aced (formerly Exponent)’s knowledge base. No account or API key required.

Open this URL with your own question, URL-encoded. Include your question in q. All research inputs are optional; no account or setup.

`GET https://www.aced.io/agents/agent/faq?q={question}&trace=t_679ff9ab98f3`

[Tool guide and examples](https://www.aced.io/agents/agent-access) · [OpenAPI](https://www.aced.io/agents/api/public/v1/openapi.json) · [Page TLDR form](https://www.aced.io/agents/agent-tools/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F3105%2Fe-commerce-part-4). Opening a form does not execute a tool.