Exam DSA-C03 Topic 1 Question 175 Discussion
Actual exam question for Snowflake's DSA-C03 exam
Question #: 175
Topic #: 1
Question #: 175
Topic #: 1
A data scientist needs to calculate the cumulative moving average of sales for each product in a table. The table contains columns: (INT), (DATE), and (NUMBER). The desired output should include the product_id', 'sale_date', and Which of the following Snowflake SQL statements correctly calculates the cumulative moving average for each product using window functions?
Suggested Answer: B,D Vote an answer
Both options B and D are correct. Option B correctly uses the 'AVG()' window function with the 'PARTITION BY product_id' clause to calculate the average sales for each product independently, and 'ORDER BY sale_date ASC' along with 'ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW' ensures a cumulative average is calculated from the beginning of the product's sales history up to the current date. Option D also calculates the cumulative moving average by summing the and dividing by the current row number, effectively computing the average.
by Isidore at Jul 26, 2025, 06:07 PM
0
0
0
10
Comments
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Report Comment
Commenting
You can sign-up / login (it's free).