# High-Value Electronics

> The five priciest electronics.

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

Domain: SQL · Difficulty: easy · Seniority: L3

## Problem

The procurement team is reviewing what it costs to stock the electronics shelf. They want to see the name and price of in-stock electronics priced above two hundred dollars. Show only the five most expensive options, listed from highest price to lowest.

## Worked solution and explanation

### Why this problem exists in real interviews

Multi-condition filtering (category + price) tests compound WHERE clause construction. This verifies you can combine string and numeric predicates.

---

### Break down the requirements

#### Step 1: Filter by category and price

`WHERE category = 'electronics' AND price > 500` combines both conditions.

---

### The solution

**Compound WHERE for category and price**

```sql
SELECT product_name, price
FROM products
WHERE category = 'electronics'
  AND price > 500
ORDER BY price DESC
```

> **Cost Analysis**
>
> A composite index on `(category, price)` makes this a narrow range scan.

> **Interviewers Watch For**
>
> This is a warm-up. The interviewer verifies AND vs. OR logic.

> **Common Pitfall**
>
> Case sensitivity: check whether the data stores 'electronics' or 'Electronics'.

---

## Common follow-up questions

- What index optimizes this query? _(Tests composite index (category, price).)_
- How would you include a second category? _(Tests IN clause.)_
- What if you wanted the count instead? _(Tests replacing SELECT with COUNT(*).)_

## Related

- [All practice problems](https://datadriven.io/problems)
- [Mock interview mode](https://datadriven.io/interview/high_value_electronics)
- [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.