# Low Uptime Services

> Underperforming services.

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

Domain: SQL · Difficulty: easy · Seniority: L3

## Problem

The SRE team set a 95% uptime SLA and needs to surface every health check that fell short. Show the service name, check date, and uptime for each violation.

## Worked solution and explanation

### Why this problem exists in real interviews

Querying svc_health for svc_name data using query construction tests whether you can translate a business requirement into the right column references and filter sequence. It shows up as a fundamentals check to verify practical fluency.

---

### Break down the requirements

#### Step 1: Filter to the target rows

Apply the `WHERE` filter to restrict the working set before aggregation. Filtering early reduces the number of rows that downstream operations process.

#### Step 2: Order the final output

Apply `ORDER BY` as specified to produce the expected row sequence. When tied values exist, add a secondary sort column for determinism.

---

### The solution

**SLA violation filter**

```sql
SELECT svc_name, checked, uptime
FROM svc_health
WHERE uptime < 95.0
ORDER BY uptime ASC
```

> **Cost Analysis**
>
> The query scans 30M rows from `svc_health`.

> **Interviewers Watch For**
>
> Candidates who verbalize their approach before typing, naming the output columns and expected row count, consistently perform better.

> **Common Pitfall**
>
> Comparing dates stored as TEXT without casting can produce lexicographic instead of chronological ordering. Always confirm the column type.

---

## Common follow-up questions

- What happens to your result if svc_health.latency contains NULLs for some rows? _(Tests whether the candidate accounts for NULL behavior in aggregates and comparisons on latency.)_
- How would you verify that your aggregation on svc_health.check_id is not double-counting due to duplicate rows? _(Tests data quality awareness and deduplication strategies.)_
- With millions of distinct values in svc_health.check_id, what index strategy would you use to keep this query performant? _(Tests indexing knowledge specific to high-cardinality columns like check_id.)_

## Related

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