Challenge: 7-Day Moving Average of Sales
Aufgabe
Swipe to start coding
Write a query to calculate the 7-day moving average of the amount for each employee_id, ordered by sale_date.
- Use a window function to partition the data by
employee_id. - Order the rows within each partition by
sale_date. - Compute the average of
amountfor the current row and the previous 6 rows within the partition. - Output the columns:
sale_id,sale_date,employee_id,amount, and the calculated 7-day moving average asmoving_avg_7d. - Order the final results by
employee_idandsale_date.
Lösung
War alles klar?
Danke für Ihr Feedback!
Abschnitt 1. Kapitel 6
single
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen
Suggested prompts:
Can you explain that in more detail?
What are the main benefits or drawbacks?
Can you give me an example?
Großartig!
Completion Rate verbessert auf 4.55
Challenge: 7-Day Moving Average of Sales
Swipe um das Menü anzuzeigen
Aufgabe
Swipe to start coding
Write a query to calculate the 7-day moving average of the amount for each employee_id, ordered by sale_date.
- Use a window function to partition the data by
employee_id. - Order the rows within each partition by
sale_date. - Compute the average of
amountfor the current row and the previous 6 rows within the partition. - Output the columns:
sale_id,sale_date,employee_id,amount, and the calculated 7-day moving average asmoving_avg_7d. - Order the final results by
employee_idandsale_date.
Lösung
War alles klar?
Danke für Ihr Feedback!
Abschnitt 1. Kapitel 6
single