# Device Types With Chrome Users

> Power users and their devices.

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

Domain: SQL · Difficulty: easy · Seniority: L3

## Problem

The frontend team is deciding which device types to prioritize for a Chrome-specific optimization. Show device types that have at least 2 Chrome users, with the user count for each, sorted from largest to smallest.

## Worked solution and explanation

### Why this problem exists in real interviews

This tests filtered GROUP BY with HAVING on a count. Combining a browser filter with a minimum-count threshold per device type is a standard aggregation pattern.

---

### Break down the requirements

#### Step 1: Filter to Chrome users

`WHERE browser = 'Chrome'` restricts to Chrome browser records.

#### Step 2: Group by device type

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

#### Step 3: Filter and sort

`HAVING COUNT(*) >= 2` removes device types with too few Chrome users. `ORDER BY COUNT(*) DESC`.

---

### The solution

**Filtered count with HAVING threshold**

```sql
SELECT device_type, COUNT(*) AS chrome_users
FROM devices
WHERE browser = 'Chrome'
GROUP BY device_type
HAVING COUNT(*) >= 2
ORDER BY chrome_users DESC
```

> **Cost Analysis**
>
> Scan of 3M rows filtered to Chrome. GROUP BY on a few device types. Trivially fast.

> **Interviewers Watch For**
>
> Whether the candidate applies the browser filter in WHERE (before grouping) and the count threshold in HAVING (after grouping). This WHERE/HAVING distinction is fundamental.

> **Common Pitfall**
>
> Putting `browser = 'Chrome'` in HAVING would be a logical error, since it is a row-level condition, not an aggregate condition.

---

## Common follow-up questions

- What if 'Chrome' appears in different cases? _(Tests LOWER(browser) = 'chrome' for case-insensitive matching.)_
- How would you count distinct users instead of devices? _(Need a user_id column or join to sessions; depends on the schema.)_
- How would you show device types with NO Chrome users? _(Tests anti-pattern: all types minus Chrome types, or conditional having.)_

## Related

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