Question 2 of 72
Single answerYour company has several retail locations. Your company tracks the total number of sales made at each location each day. You want to use SQL to calculate the weekly moving average of sales by location to identify trends for each store. Which query should you use?
A. SELECT store_id, date, total_sales, AVG(total_sales) OVER ( PARTITION BY store_id ORDER BY total_sales RANGE BETWEEN 6 PRECEDING AND CURRENT ROW ) as rolling_avg FROM store_sales_daily
B. SELECT store_id, date, total_sales, AVG(total_sales) OVER ( PARTITION BY date ORDER BY store_id ROWS BETWEEN 6 PRECEDING AND CURRENT ROW ) as rolling_avg FROM store_sales_daily
C. SELECT store_id, date, total_sales, AVG(total_sales) OVER ( PARTITION BY store_id ORDER BY date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW ) as rolling_avg FROM store_sales_daily
D. SELECT store_id, date, total_sales, AVG(total_sales) OVER ( PARTITION BY total_sales ORDER BY date RANGE BETWEEN 6 PRECEDING AND CURRENT ROW ) as rolling_avg FROM store_sales_daily
<p>C. SELECT store_id, date, total_sales, AVG(total_sales) OVER ( PARTITION BY store_id ORDER BY date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW ) as rolling_avg FROM store_sales_daily</p>
The correct answer is highlighted above. Review the wording carefully, then use the next question to continue building your understanding of Google certification topics.