# E-commerce (5 of 5): second-earliest orders by customer and date | Aced

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/3106/e-commerce-part-5
Source observed: 2026-11-04T21:34:36.332Z
Last checked: 2026-11-04T21:34:36.332+00:00
Indexed: 2026-11-05T01:45:50.012+00:00

---

# E-commerce (5 of 5)

**Hard SQL coding question**

We provide interview preparation and coding practice through Aced (formerly Exponent). This question uses an Amazon e-commerce scenario: customers can order items ranging from electronics to clothing.

## Problem

You receive two tables, `orders` and `items`.

### `orders`

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

### `items`

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

Write a SQL query that returns the second-earliest `order_id` for each customer on each date when that customer placed at least two orders.

The output must contain:

- `customer_id`
- `order_date`
- `second_earliest_order_id`

Order the results by `order_date` and then `customer_id`.

## Question context and controls

- Category: [Coding](https://www.aced.io/questions?type=coding)
- Topic: [SQL](https://www.aced.io/questions?type=sql)
- Difficulty: Hard
- Reported interview count: 1
- Community count: 42
- Detailed company statistics require [an upgrade](https://www.aced.io/upgrade?src=questions).
- The page provides editor, share, output, test-results, and console areas. Running code requires [sign-up](https://www.aced.io/signup?src=lesson).

## Five-part e-commerce series

This is the fifth and final question in the series. The preceding 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: Earliest Order by Customer](https://www.tryexponent.com/courses/sql-interviews/e-commerce-iv) — 4 of 5

## Related questions

- [E-commerce (4 of 5)](https://www.aced.io/questions/3105/e-commerce-part-4)
- [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)

[Browse all questions](https://www.aced.io/questions)

---

[Read this page’s summary](https://www.aced.io/agents/api/public/v1/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F3106%2Fe-commerce-part-5&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%2F3106%2Fe-commerce-part-5). Opening a form does not execute a tool.