# Deployed Models by Framework

> Which frameworks are actually in production?

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

Domain: SQL · Difficulty: easy · Seniority: L3

## Problem

In the ML model registry, how many deployed models exist for each framework? Rank from most to fewest.

## Worked solution and explanation

### Why this problem exists in real interviews

This tests filtered GROUP BY with COUNT and ORDER BY. It verifies that you can apply a WHERE filter before aggregation and sort correctly.

---

### Break down the requirements

#### Step 1: Filter to deployed models

`WHERE status = 'deployed'` restricts to active models.

#### Step 2: Count per framework

`GROUP BY framework` with `COUNT(*)`.

#### Step 3: Sort descending

Most models first.

---

### The solution

**Filtered count per group**

```sql
SELECT framework, COUNT(*) AS model_count
FROM ml_models
WHERE status = 'deployed'
GROUP BY framework
ORDER BY model_count DESC
```

> **Cost Analysis**
>
> Scan of 2,500 rows. Trivially fast.

> **Interviewers Watch For**
>
> Whether the candidate filters before grouping (WHERE) vs after (HAVING). WHERE is correct here since the filter is on individual rows, not aggregates.

> **Common Pitfall**
>
> Using HAVING COUNT(*) for the deployed filter would not work. HAVING is for aggregate conditions; row-level conditions belong in WHERE.

---

## Common follow-up questions

- How would you also show the average accuracy per framework? _(Add AVG(accuracy) to the SELECT.)_
- What if status values are inconsistent (e.g., 'Deployed' vs 'deployed')? _(Tests LOWER() for case-insensitive matching.)_
- How would you find frameworks with both deployed and deprecated models? _(Tests conditional HAVING with SUM(CASE).)_

## Related

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