# Most Recent Transaction — SQL Interview Question

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/3043/most-recent-transaction
Source observed: 2026-11-04T21:34:37.928Z
Last checked: 2026-11-04T21:34:37.928+00:00
Indexed: 2026-11-05T06:36:24.234+00:00

---

# Most Recent Transaction

We provide this medium-difficulty SQL coding question for interview preparation. It asks you to query an e-commerce database and return the **name** and **stock** of the product involved in the most recently purchased transaction.

- **Interview reports:** 5 interviews
- **Last asked:** a year ago
- **Roles:** [Data Engineer](https://www.aced.io/questions?role=data-engineer), [Data Scientist](https://www.aced.io/questions?role=data-science), [Data Analyst](https://www.aced.io/questions?role=data-analyst), [Software Engineer](https://www.aced.io/questions?role=swe)
- **Company:** [Amazon](https://www.aced.io/questions?company=amazon)
- **Categories:** [Coding](https://www.aced.io/questions?type=coding), [SQL](https://www.aced.io/questions?type=sql)

## Question

Given an e-commerce database with the schema shown below, write a query to fetch the product name and stock of the most recently purchased product.

![E-commerce database schema diagram](https://images.ctfassets.net/x78yjrjc11pq/2xnAuvqOHeLAQgYjeNgm4J/227f4525afd76eb0a90b0160bda8417d/Screenshot_2026-04-22_at_4.47.30%C3%A2__PM.png)

The schema diagram identifies these tables and fields:

- `users`: `id` (integer, primary key), `first_name` (varchar), `last_name` (varchar), `user_city` (integer), `email` (integer)
- `transactions`: `id` (integer, primary key), `customer_id` (integer, foreign key), `product_id` (integer, foreign key), `amount` (integer), `currency_code` (varchar), `date` (date)
- `products`: `id` (integer, primary key), `name` (varchar), `product_line_id` (integer, foreign key), `stock` (integer)
- `product_lines`: `id` (integer, primary key), `name` (varchar)
- `exchange_rate`: `id` (integer, primary key), `source_currency_code`, `target_currency_code`, and `rate` (numeric)

The diagram marks primary keys, foreign keys, and their relationships. The relevant purchase-to-product relationship is represented by `transactions.product_id` and the product identifier.

Your query should return this format:

```text
id  | name    | stock
----+---------+------
int | varchar | int
```

The question and its solution are separate tabs. The solution is not included in the supplied content. The embedded SQL editor includes a SQLite selection, Editor and Share tabs, Output and Test Results tabs, and a Console; sign-up is required to run code: [Sign up to run code](https://www.aced.io/signup?src=lesson).

## Interview experience

One shared experience concerns an Amazon Software Engineer interview at the mid-level/L4 level, reported two years ago:

> “There is not that much interaction with a recruiter. I was lucky in the coding question was not hard but they have a bank essentially similar to leetcode mediums. The bar raiser round you should prepare stories for each one”

[Read the Amazon interview experience](https://www.aced.io/experiences/amazon-software-engineer-interview-7eac4b)

## Related questions

- [Fraudulent Transactions](https://www.aced.io/questions/3071/fraudulent-transactions)
- [Total Transaction Volume](https://www.aced.io/questions/3042/total-transaction-volume)

## Related courses

### [Data Analyst Interview Prep](https://www.aced.io/courses/data-analytics)

![Data Analyst Interview Prep](https://images.ctfassets.net/x78yjrjc11pq/72OTqij57b2TklhaD2vrdV/be0dae6242904970d1696e5a4d858e18/AdobeStock_1357126576.jpeg?w=800&h=800&fm=webp&q=75)

We help you prepare for data analyst interviews across product, marketing, and business analyst roles with real take-home case studies, technical and dashboarding practice, and strategies from interviewers at technology companies and startups.

### [Data Science Interview Prep](https://www.aced.io/courses/data-science)

![Data Science Interview Prep](https://images.ctfassets.net/x78yjrjc11pq/3U4C5C0OkDR0UeGch4AmlE/7ad489430b676a088cb973307fe77884/Data_Science_Interview_Prep_Course.jpeg?w=800&h=800&fm=webp&q=75)

We help you prepare for data science roles at Google, Amazon, Microsoft, Meta, Apple, and other companies through mock interviews, frameworks, and advice from senior candidates. Practice covers statistics, experimentation, coding, SQL, machine learning, behavioral interviews, and more.

[Browse all questions](https://www.aced.io/questions) · [Upgrade for detailed company stats](https://www.aced.io/upgrade?src=questions)

---

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