# Distinct Product Categories

> A quick category inventory.

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

Domain: SQL · Difficulty: easy · Seniority: L3

## Problem

The merchandising team is mapping out the full product taxonomy. Pull a deduplicated list of every product category currently in the catalog.

## Worked solution and explanation

### Why this problem exists in real interviews

This is a simple DISTINCT query. It screens for the most basic deduplication operation in SQL.

---

### Break down the requirements

#### Step 1: Deduplicate categories

`SELECT DISTINCT category` returns unique category values.

---

### The solution

**Simple deduplication**

```sql
SELECT DISTINCT category
FROM products
```

> **Cost Analysis**
>
> Scan of 15K rows. Trivially fast.

> **Interviewers Watch For**
>
> Whether the candidate keeps it simple. This is a one-statement query.

> **Common Pitfall**
>
> Using GROUP BY category without any aggregates is equivalent but less semantically clear for this use case. DISTINCT is idiomatic for simple deduplication.

---

## Common follow-up questions

- When would GROUP BY be preferred over DISTINCT? _(When you also need aggregates like COUNT or SUM.)_
- What if category has NULLs? _(NULL appears as a distinct value. Tests whether to filter it.)_
- How would you sort the categories alphabetically? _(Add ORDER BY category.)_

## Related

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