# Cheapest Cost Per Region

> Lowest spend per region.

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

Domain: SQL · Difficulty: easy · Seniority: L3

## Problem

The FinOps team wants to know the floor price they're paying in each region. Show the minimum cloud cost amount recorded for each region.

## Worked solution and explanation

### Why this problem exists in real interviews

This is a basic GROUP BY with MIN aggregation. It screens for fundamental SQL competence: grouping by a dimension and extracting a single aggregate per group.

---

### Break down the requirements

#### Step 1: Group by region

`GROUP BY region` produces one row per region.

#### Step 2: Find minimum amount

`MIN(amount)` returns the floor price per region.

---

### The solution

**Simple group-and-min**

```sql
SELECT region, MIN(amount) AS min_cost
FROM cloud_costs
GROUP BY region
```

> **Cost Analysis**
>
> Single scan of 6M rows with in-memory aggregation. The GROUP BY output is a handful of regions. Trivially fast.

> **Common Pitfall**
>
> If `amount` contains NULLs, `MIN` ignores them automatically. But if all amounts in a region are NULL, the result is NULL, which might need a COALESCE depending on requirements.

---

## Common follow-up questions

- What if you also needed the service name associated with the minimum cost? _(Tests DISTINCT ON, window functions, or correlated subqueries for first-per-group.)_
- How does MIN handle NULL values? _(MIN ignores NULLs. Tests awareness of NULL aggregate behavior.)_
- What if you needed both the min and max cost per region? _(Simply add MAX(amount); tests comfort with multiple aggregates in one query.)_

## Related

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