Problem Statement

Write SQL queries for running totals using window functions: sales(id, salesperson, region, amount, sale_date) 1. Calculate running total of sales amount ordered by date 2. Calculate running total per salesperson (reset for each person) 3. Calculate 3-day moving average of sales amount

Sample Data

sales:
(1,'Alice','North',5000,'2024-01-01'), (2,'Bob','South',3000,'2024-01-02'),
(3,'Alice','North',4000,'2024-01-03'), (4,'Bob','South',6000,'2024-01-04'),
(5,'Alice','North',2000,'2024-01-05')

Expected Output

Q1: 5000, 8000, 12000, 18000, 20000
Q2: Alice: 5000,9000,11000  Bob: 3000,9000
Q3: Moving avg over 3 rows

Your Submission

ℹ️ The AI reads and reviews your code — it does not run it. Runtime errors like missing files or wrong paths won't affect your score. Focus on writing clean, correct logic.
Submit your work — choose one or more options
OR
OR