Quadrint analysts need a product-level revenue trend for a reporting surface such as the Mission Operations Dashboard. Write a PostgreSQL query that summarizes completed sales by product and day, then calculates each product's running revenue total.
Requirements
- Include only sales with
sale_status = 'completed' and matching products.
- Aggregate multiple sales for the same product and date into
daily_revenue.
- Use a window function partitioned by product and ordered chronologically to calculate
running_total.
- Treat NULL sale amounts as zero for the daily aggregation, and sort the final output by product name and date.