# Inactive Android Control Users

> Android control cohort. Gone quiet.

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

Domain: SQL · Difficulty: medium · Seniority: L3

## Problem

Find users in the 'control' variant on 'android' whose account status is not 'active'. Show their user ID, platform, and variant, ordered by experiment creation date ascending.

## Worked solution and explanation

### What this is really asking

`account_status != 'active'` looks innocent but quietly drops every NULL row, that is the one line worth staring at. The rest is a vanilla inner join with two equality filters and ORDER BY experiments.created.

---

### Break down the requirements

#### Step 1: Filter experiments first

variant='control' AND platform='android' on the 1.5M-row table. Push both predicates down before the join to shrink the probe.

#### Step 2: Inner-join to users

Join on user_id, then filter u.account_status != 'active'. INNER is correct: a missing user row cannot satisfy the status predicate.

---

### The solution

**INACTIVE ANDROID CONTROL USERS**

```sql
SELECT e.user_id, e.platform, e.variant
FROM experiments e
INNER JOIN users u ON e.user_id = u.user_id
WHERE e.variant = 'control'
  AND e.platform = 'android'
  AND u.account_status <> 'active'
ORDER BY e.created ASC;
```

> **Cost Analysis**
>
> experiments(variant, platform, created) lets the filter and ORDER BY share one index. Join into users(10M) on the user_id PK is one lookup per surviving row.

> **Interviewers Watch For**
>
> Whether you flag NULL handling. NULL <> 'active' is UNKNOWN and excluded; if 'not active' should include NULL, use `IS DISTINCT FROM`.

> **Common Pitfall**
>
> Putting `account_status != 'active'` into the ON clause of a LEFT JOIN keeps unmatched rows with NULL status. INNER JOIN with the predicate in WHERE avoids it.

---

### COMMON FOLLOW-UP QUESTIONS

## Common follow-up questions

- What if a user has multiple experiments rows for the same exp_id? _(One per assignment or one per user: add DISTINCT or aggregate by user_id.)_
- How would you compare inactive rates across control and treatment on android? _(GROUP BY variant, count user_ids with status != 'active' over totals, then take the ratio.)_
- What index covers this for an hourly run? _(Composite on experiments(variant, platform, created); users.user_id is already the PK.)_

## Related

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