# Error Hall of Fame

> The year's worst error categories.

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

Domain: SQL · Difficulty: medium · Seniority: L3

## Problem

The error_logs table captures events from 2025. Show each error type and how many times it occurred, sorted from most frequent to least.

## Worked solution and explanation

### Why this problem exists in real interviews

Top-N error queries test aggregation and ranking. The prompt asks for each error type's total occurrences, which means summing the `count` column (pre-aggregated counts), not using `COUNT(*)`.

---

### Break down the requirements

#### Step 1: Aggregate by error type

`GROUP BY err_type` with `SUM(count)` gives total occurrences per error type (since `count` stores pre-aggregated values).

#### Step 2: Order descending

`ORDER BY total_occurrences DESC` surfaces the most frequent error type first.

---

### The solution

**Aggregate pre-counted errors by type**

```sql
SELECT err_type, SUM(count) AS total_occurrences
FROM err_tracks
GROUP BY err_type
ORDER BY total_occurrences DESC
```

> **Cost Analysis**
>
> Hash aggregation with low cardinality grouping key. Very fast even on large tables.

> **Interviewers Watch For**
>
> Strong candidates notice that `count` is a pre-aggregated column and use `SUM(count)` instead of `COUNT(*)`, which would only count rows.

> **Common Pitfall**
>
> Using `COUNT(*)` instead of `SUM(count)` counts rows, not occurrences. If each row represents multiple occurrences, COUNT undercounts.

---

## Common follow-up questions

- How would you include ties at the last position? _(Tests DENSE_RANK instead of LIMIT.)_
- What if you wanted the top error per service? _(Tests PARTITION BY in a window function.)_
- How would you compute top errors over a rolling window? _(Tests date filtering with the ranking.)_

## Related

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