# Top 10 Model Accuracies

> Top ten model performance.

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

Domain: SQL · Difficulty: easy · Seniority: L3

## Problem

Surface the 10 highest accuracy values across all models in the ML registry, showing each model's name and accuracy.

## Worked solution and explanation

### Why this problem exists in real interviews

Ranking ML models by accuracy is a simple top-N pattern that verifies you can order by a numeric metric and apply LIMIT.

---

### Break down the requirements

#### Step 1: Order by accuracy

`ORDER BY accuracy DESC` ranks models from highest to lowest.

#### Step 2: Limit to 10

`LIMIT 10` returns the top 10.

---

### The solution

**Simple ranking by accuracy metric**

```sql
SELECT model_name, accuracy
FROM ml_models
ORDER BY accuracy DESC
LIMIT 10
```

> **Cost Analysis**
>
> A trivial query on a small reference table. Sorting a few hundred to thousand records is instant.

> **Interviewers Watch For**
>
> Interviewers may ask whether accuracy alone is sufficient. Strong candidates mention that precision, recall, or F1 might be more appropriate on imbalanced datasets.

> **Common Pitfall**
>
> Assuming higher accuracy is always better. On imbalanced problems, a model predicting the majority class can have 99% accuracy but be useless.

---

## Common follow-up questions

- What if you needed the top model per framework? _(Tests PARTITION BY framework with ROW_NUMBER.)_
- How would you also include training date and dataset size? _(Tests adding columns without changing the ranking.)_
- What if models have multiple accuracy scores across test sets? _(Tests aggregating accuracy before ranking.)_

## Related

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