Disabled 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
Vesta Innovations

Problem

The platform team is auditing stale feature flags that may be safe to remove. Pull all flags that are currently disabled, showing every column.

Disabled flags. Still worth auditing.

Tables

feat_flags

Columns: flag_id INTEGER, flag_name TEXT, enabled INTEGER, rollout REAL, owner TEXT, created TEXT, updated TEXT

feat_flags: 10 of 200 rows
flag_idflag_nameenabledrolloutownercreatedupdated
131new_checkout0NULLengineering2025-02-022026-02-02
162beta_search0NULLgrowth2025-03-032026-03-03
193ai_recs139platform2025-04-042026-04-04
224live_chat0NULLmobile2025-05-052026-05-05
255video_upload0NULLdata2025-06-062026-06-06
286two_factor178product2025-07-072026-07-07
317bulk_export0NULLengineering2025-08-082026-08-08
348new_dashboard0NULLgrowth2025-09-092026-09-09
379mobile_v2117platform2025-10-102026-01-10
410dark_mode0NULLmobile2025-11-112026-02-11

Expected output

First 5 of 134 rows
flag_idflag_nameenabledrolloutownercreatedupdated
131new_checkout0NULLengineering2025-02-022026-02-02
162beta_search0NULLgrowth2025-03-032026-03-03
224live_chat0NULLmobile2025-05-052026-05-05
255video_upload0NULLdata2025-06-062026-06-06
317bulk_export0NULLengineering2025-08-082026-08-08

Worked solution and explanation

What this really is

Strip the audit story away and this is one predicate: keep the rows whose stored state is off. The whole question is where 'off' lives. In feat_flags it lives in enabled, an integer that is 0 or 1. Candidates who skim the sample rows often notice the blank rollout cells first and filter on those, or type enabled = 'false' as if the column were text. The first happens to line up on this data and breaks the day someone switches off a flag without clearing its rollout percentage. The second compares an integer to a word, matches nothing, and hands the auditor an empty list.

Step 1: Find where the off state is stored

Read the column types before reading the rows. enabled is an INTEGER holding 0 or 1, so 'off' is the value 0. rollout is a percentage that only gets filled in for live flags. It is a side effect of the state, not the state itself.

Step 2: Keep only the off rows

enabled = false and enabled = 0 are the same test here, because the engine treats false as 0. What matters is comparing against the number. Of the 200 flags, 134 survive; the 66 live ones never reach the reviewer.

Step 3: Return the whole row

The auditor wants every column, so the projection is *. A hand-picked column list is exactly the kind of thing that silently drops owner or updated, and the reviewer needs both to decide who to ask before deleting a flag.

Disabled flags, whole rows
SELECT *
FROM feat_flags
WHERE enabled = false

One pass over feat_flags, keeping the rows where enabled is 0.


Common follow-up questions