# Unsold Products — SQL 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/4376/unsold-products
Source observed: 2026-11-05T01:11:24.837Z
Last checked: 2026-11-05T01:11:24.837+00:00
Indexed: 2026-11-07T04:02:05.31+00:00

---

# Unsold Products

**Difficulty:** Easy  
**Format:** SQL question

Given the schema below, write a solution that returns the name and stock of every product that has never been purchased, if any. Order the results by product ID.

## Schema

```text
users
+---------------+---------+
| id            | int     |
| first_name    | varchar |
| last_name     | varchar |
| user_city     | int     |
| email         | int     |
+---------------+---------+

products
+-----------------+---------+
| id              | int     |
| name            | varchar |
| product_line_id | date    |
| stock           | int     |
+-----------------+---------+

transactions
+---------------+---------+
| id            | int     |
| customer_id   | int     |
| product_id    | int     |
| amount        | int     |
| currency_code | varchar |
| date          | date    |
+---------------+---------+

product_lines
+--------+---------+
| id     | int     |
| name   | varchar |
+--------+---------+

exchange_rate
+----------------------+---------+
| id                   | int     |
| source_currency_code | varchar |
| target_currency_code | varchar |
| rate                 | numeric |
+----------------------+---------+
```

The schema diagram indicates that `transactions.product_id` relates to `products.id`, `transactions.customer_id` relates to `users.id`, and `products.product_line_id` relates to `product_lines.id`.

## Required result format

Return these columns:

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

The result must be ordered by product ID. Products with no matching purchase transaction should be included; if none exist, return no rows.

## Page controls and access

The question interface provides **Question**, **Solution**, and **Community13** tabs. No community answers have been contributed yet. The interactive editor includes **Editor**, **Share**, **Output**, **Test Results**, and **Console** controls. Running code requires an Aced account: [Sign up to run code](https://www.aced.io/signup?src=lesson).

Aced (formerly Exponent) provides interview-preparation courses, practice questions, and coaching. Its listed course areas include Product Management, Forward Deployed Engineering, Engineering Management, Software Engineering, System Design, Data Science, Machine Learning, and Data Engineering, along with additional technical and business tracks.

[All Questions](https://www.aced.io/questions) · [Aced home](https://www.aced.io/?src=nav)

---

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