Platform Team Feature Flags
An easy SQL interview practice problem on DataDriven. Write the query and run it against a real database, with instant feedback.
- Domain
- SQL
- Difficulty
- easy
- Seniority
- L3
- Asked in
- City and County of San Francisco
Problem
Ahead of a major release, the platform team is auditing every feature flag it owns in feat_flags. Pull back all of their fields.
The platform team owns a lot of flags.
Tables
feat_flags
Columns: flag_id INTEGER, flag_name TEXT, enabled INTEGER, rollout REAL, owner TEXT, created TEXT, updated TEXT
| flag_id | flag_name | enabled | rollout | owner | created | updated |
|---|---|---|---|---|---|---|
| 131 | new_checkout | 0 | NULL | engineering | 2025-02-02 | 2026-02-02 |
| 162 | beta_search | 0 | NULL | growth | 2025-03-03 | 2026-03-03 |
| 193 | ai_recs | 1 | 39 | platform | 2025-04-04 | 2026-04-04 |
| 224 | live_chat | 0 | NULL | mobile | 2025-05-05 | 2026-05-05 |
| 255 | video_upload | 0 | NULL | data | 2025-06-06 | 2026-06-06 |
| 286 | two_factor | 1 | 78 | product | 2025-07-07 | 2026-07-07 |
| 317 | bulk_export | 0 | NULL | engineering | 2025-08-08 | 2026-08-08 |
| 348 | new_dashboard | 0 | NULL | growth | 2025-09-09 | 2026-09-09 |
| 379 | mobile_v2 | 1 | 17 | platform | 2025-10-10 | 2026-01-10 |
| 410 | dark_mode | 0 | NULL | mobile | 2025-11-11 | 2026-02-11 |
Expected output
| flag_id | flag_name | enabled | rollout | owner | created | updated |
|---|---|---|---|---|---|---|
| 193 | ai_recs | 1 | 39 | platform | 2025-04-04 | 2026-04-04 |
| 379 | mobile_v2 | 1 | 17 | platform | 2025-10-10 | 2026-01-10 |
| 565 | video_upload | 1 | 95 | platform | 2025-04-16 | 2026-07-16 |
| 751 | new_checkout | 1 | 73 | platform | 2025-10-22 | 2026-04-22 |
| 937 | bulk_export | 1 | 51 | platform | 2025-04-28 | 2026-01-28 |
Worked solution and explanation
Two requirements hiding in one sentence
This is a row-scoping problem wearing a 'give me everything' costume. 'All fields' settles the columns; 'every flag they own' is a second, separate requirement that settles the rows, and it is the one people read past. Everyone writes SELECT *. The candidate who stops there hands back all 200 flags in feat_flags, and the platform team audits 166 flags that belong to five other teams the week before their release.
Getting there
Step 1: Settle the columns
'All fields' means every column of feat_flags, in the table's own order. SELECT * says exactly that, and here it is the honest answer: an audit wants rollout, created and updated next to the name, and a hand-typed list only gives you a chance to drop one.
Step 2: Scope the rows to the owner
'They own' points at the owner column, which holds team names. The sample rows and the preview both show the literal 'platform', so WHERE owner = 'platform' cuts 200 rows to 34. That predicate is the whole problem.
Step 3: Leave the order alone
An inventory pull is a set the team will scan, not a list read top-down. Nothing asks for an order, so there is no ORDER BY to add.
SELECT *
FROM feat_flags
WHERE owner = 'platform'- Reads only 'all fields'
SELECT * FROM feat_flagsreturns 200 rows from six owners. The columns are right and the audit is wrong.- Reads both requirements
- Adding
WHERE owner = 'platform'returns the 34 flags the team actually owns, with every column intact.
Common follow-up questions
- What changes if `owner` were typed by hand and held 'Platform' and ' platform' as well? (Tests whether the candidate normalizes case and whitespace before matching instead of trusting the literal.)
- The team now wants only flags that are live. What do you add, and what does a `NULL` `rollout` tell you about a flag? (Tests reading the relationship between `enabled` and `rollout` rather than guessing a filter.)
- How would you return how many flags each team owns instead of the flags themselves? (Tests moving from a row filter to a per-owner count.)