Retail · SQL
Isolating a clean customer baseline by filtering duplicate flags in SQL
Independent grading: 100/100(verify, opens in a new tab)
Problem
Meridian Retail (simulated retailer) had different teams reporting different customer counts, creating uncertainty about which figure to use as a baseline. The seniors were investigating the root cause, and my piece of the work was to produce the single authoritative clean count. The question was: how many customer records are legitimate once duplicates are excluded?
What I did
Filtering on the boolean is_duplicate column was the direct route, so I wrote a WHERE clause using is_duplicate = FALSE to isolate only valid rows. From that filtered set, COUNT(*) captures every qualifying row regardless of null values in other columns, which is the right aggregation when the goal is a row count rather than a field-level count. Aliasing the result as clean_customer_count meant the output column name answered the question without requiring further explanation.
Finding
The clean customer count is 2,131, the verified baseline for all downstream comparisons.
Outcome
Meridian now has a single agreed-upon number to anchor customer-level reporting, removing the ambiguity between team figures.
SELECT COUNT(*) AS clean_customer_count FROM customers WHERE is_duplicate = FALSE;
This query filters to non-duplicate rows and counts them with a self-documenting alias, producing the single baseline figure the team needed.
Next step
A useful next step would be to break the 2,131 clean customers down by acquisition channel or registration date, to understand whether the duplicate problem is concentrated in a particular cohort.
- Boolean row filtering in SQL (WHERE is_duplicate = FALSE)
- SQL COUNT with aliasing
- Column aliasing for self-documenting output