Hard
Advanced SQL Window Functions
Construct a complex query using window functions to analyze time-series data.
📝 Contenu du Prompt
Write a PostgreSQL query that calculates the 3-day moving average of sales for each product, alongside the difference from the previous day's sales, partitioned by store location. Handle NULL values by carrying forward the last known value using the IGNORE NULLS option within the window frame.