Flag Year-Over-Year Consumption Spikes Before Bills Go Out
Last updated: November 29, 2026
Quick Overview
Given a table of monthly consumption per account with a read type (actual or estimated), write SQL that flags accounts whose usage this November is at least 50 percent and 100 kWh higher than last November, so they can be reviewed before billing.
Fuse Energy
November 29, 20260
0
0 solved
Given a table of monthly consumption per account with a read type (actual or estimated), write SQL that flags accounts whose usage this November is at least 50 percent and 100 kWh higher than last November, so they can be reviewed before billing.
Bill shock drives complaints and churn for an energy supplier, and Fuse's operations team would want suspicious jumps caught before customers see them. The SQL screen tests self-joins on period, sensible thresholds that avoid tiny-base noise, and awareness that estimated reads cause most false spikes.
What the Interviewer Expects
- Compare the same month across years, not consecutive months, to control for seasonality
- Combine relative and absolute thresholds to avoid flagging tiny bases
- Exclude or handle accounts with no prior-year history
- Surface read type so analysts can see estimate-driven spikes
- Order output by severity
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you make the comparison weather adjusted using degree days?
- How would you write this for every month at once, using a window function instead of hardcoded dates?
- An account moved home in the middle of the year. How do you avoid comparing two different properties?
- How would you measure whether this review step reduced complaints?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
Table monthly_usage(account_id, month DATE first-of-month, kwh, read_type 'actual'|'estimated'), one row per account per month per fuel (assume electricity only here). Accounts may be new (no last-y...
Approach
Build two CTEs for the two months, inner join on account (new customers drop out, which is intended: no baseline), then filter with three rules: baseline at least 50 kWh (ignore empty homes), relative...