# Budget-Friendly Products

> Affordable does not mean invisible.

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

Domain: SQL · Difficulty: easy · Seniority: L3

## Problem

A marketing campaign targets budget-conscious shoppers. Pull a deduplicated list of product names priced between 5 and 20 inclusive so the team can feature them in the promotion.

## Worked solution and explanation

### Why this problem exists in real interviews

The core skill being tested is filtering and projection over `products`. Candidates must decide how `product_name`, `category`, `price` interact before choosing a join strategy or aggregation level.

---

### Break down the requirements

#### Step 1: Filter `products` to qualifying rows

Apply the WHERE clause to keep only rows matching the prompt criteria. This reduces the working set before deduplication.

#### Step 2: Deduplicate with DISTINCT

`SELECT DISTINCT product_name` removes duplicate values, producing one row per unique entry.

#### Step 3: Sort the output

Order by `product_name` for deterministic, readable results.

---

### The solution

**Distinct-filter for budget-friendly products**

```sql
SELECT DISTINCT product_name
FROM products
ORDER BY product_name
```

> **Cost Analysis**
>
> The main table has 5K rows.

> **Interviewers Watch For**
>
> Clean, readable SQL with correct column references signals production readiness. Candidates who verbalize their approach before coding score higher on communication.

> **Common Pitfall**
>
> Returning extra columns not asked for, or missing a required column, are both common mistakes that fail automated grading.

---

## Common follow-up questions

- The `rating` column in `products` has roughly 6% NULLs. How does your query handle those rows, and would the result change if NULLs were replaced with zeros? _(Tests whether the candidate understands how NULLs propagate through aggregation functions and whether their WHERE/JOIN conditions implicitly filter them out.)_
- If `products` were partitioned by date, would your query need to scan all partitions or could it prune? How would you verify? _(Tests understanding of partition pruning and EXPLAIN output.)_
- The `category` column in `products` has a zipf distribution, meaning a few values dominate. How does that skew affect your query plan and parallelism? _(Tests understanding of data skew: the optimizer may choose a bad plan when histogram statistics are stale.)_
- If the business definition of `category` changed mid-quarter (e.g., a status value was renamed), how would you handle historical consistency? _(Tests awareness of slowly changing dimensions and backward-compatible query design.)_

## Related

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