for part 2 please find the link
Interview Questions
Rolling Sum (Moving Sum) is one of the most frequently asked SQL Window Function topics in data engineering, analytics, and business intelligence interviews.
In this article, we will look at different scenarios, the questions an interviewer may ask, and how you can answer them correctly.
Interview Scenario
Interviewer asks:
You have a table containing daily sales transactions:
Write an SQL query to calculate:
- Sales total for the current day and previous 2 days
- Sales total for the current day and previous 6 days
- Sales total for the current day and previous 29 days
These are called 3-day, 7-day, and 30-day rolling sums.
SQL Query
SELECT
sale_date,
amount,







