# Product Name Letter Replace

> A quick text transform on product names.

Canonical URL: <https://datadriven.io/problems/product_name_letter_replace>

Domain: SQL · Difficulty: easy · Seniority: L3

## Problem

Produce every product name with all lowercase 'e' characters swapped to uppercase 'E', listed in product ID sequence.

## Worked solution and explanation

### Why this problem exists in real interviews

The core skill being tested is string manipulation, applied to the `products` table in a product analytics context. Getting the `product_name` and `product_id` columns right is where most candidates slip.

---

### Break down the requirements

#### Step 1: Apply REPLACE function

`REPLACE(product_name, 'e', 'E')` swaps all lowercase 'e' to uppercase 'E'.

#### Step 2: Order by product_id

`ORDER BY product_id` ensures output is in ID sequence.

---

### The solution

**Apply replace function to find product name letter replace**

```sql
SELECT product_id, REPLACE(product_name, 'e', 'E') AS modified_name
FROM products
ORDER BY product_id
```

> **Cost Analysis**
>
> With `products` (10,000 rows), this query scans a small dataset. No indexing is needed for this volume. At production scale, an index on the primary filter column would improve performance.

> **Interviewers Watch For**
>
> Interviewers evaluate whether you translate the English requirements into the correct SQL clauses on the first attempt. They watch for clean syntax, correct column references, and whether you verify edge cases before declaring the query complete.

> **Common Pitfall**
>
> The most common mistake is misreading the prompt's filtering or grouping requirements. Double-check which columns to group by, which to aggregate, and whether the output should be filtered with `WHERE` (before grouping) or `HAVING` (after grouping).

---

## Common follow-up questions

- What result would you get if every value in `products.rating` were NULL? Would your query return an empty set or something unexpected? _(Tests extreme NULL scenarios and whether the candidate guards against edge cases in `rating`.)_
- The `price` column in `products` is heavily skewed toward a few popular values. How would data skew affect parallel execution of your query? _(Tests understanding of skew in `products.price` and its impact on distributed query performance.)_
- `products.in_stock` only has 2 distinct values. If a new category were added, would your query automatically include it? _(Tests whether the query hard-codes values or dynamically adapts to `in_stock` changes.)_

## Related

- [All practice problems](https://datadriven.io/problems)
- [Mock interview mode](https://datadriven.io/interview/product_name_letter_replace)
- [SQL Interview Questions](https://datadriven.io/sql-interview-questions)
- [Data Engineering Interview Prep Guide](https://datadriven.io/data-engineer-interview-prep)
- [Daily Challenge](https://datadriven.io/daily)

---

Source: DataDriven (https://datadriven.io). 100% free data engineering interview prep. Live code execution against Postgres 16, Python 3.11, and Spark sandboxes. No paywall, no premium tier, no signup gate.