Data Engineering interview question
Write SQL that calculates a 7-day rolling average of daily revenue, including days with no orders.
Hands-on Asked in Data Engineer · Machine Learning Engineer interviews
Summary
Generate a continuous date series, left join daily revenue onto it so missing days count as zero, then use a window function over the previous six rows plus the current one. Without the date series, gaps would make "7 rows" span more than seven days.
Keep reading with a membership
The full answer with examples, key points and comparisons is part of the membership, along with every other interview answer, progress tracking and Daily Review. Most-asked answers stay free to read.
More Data Engineering questions
- How do you monitor data pipelines beyond job success?
- Scenario: warehouse revenue is 4% higher than the payment provider's settlements. How do you investigate?
- What is dbt, and what problems does it solve?
- Design a daily pipeline that loads orders from an operational database into a warehouse for analytics.
- What is a star schema, and why is it used in data warehouses?
- Explain slowly changing dimensions, especially Type 1 and Type 2.
- What is change data capture (CDC), and why is log-based CDC preferred over polling?
- How do you deduplicate events, and what does 'exactly-once' really mean?