Complete the code to specify the window frame to include the current row and the two preceding rows.
SELECT sales, SUM(sales) OVER (ORDER BY date ROWS BETWEEN [1] PRECEDING AND CURRENT ROW) AS running_total FROM sales_data;The window frame specifies to include the current row and the two rows before it, so '2 PRECEDING' is correct.
Complete the code to specify the window frame to include the current row and the next three rows.
SELECT sales, SUM(sales) OVER (ORDER BY date ROWS BETWEEN CURRENT ROW AND [1] FOLLOWING) AS future_total FROM sales_data;The window frame includes the current row and the next three rows, so '3 FOLLOWING' is correct.
Fix the error in the window frame clause to correctly specify the frame from two rows before to one row after the current row.
SELECT sales, AVG(sales) OVER (ORDER BY date ROWS BETWEEN [1] PRECEDING AND [2] FOLLOWING) AS avg_sales FROM sales_data;
The frame should start two rows before ('2 PRECEDING', C) and end one row after the current row ('1 FOLLOWING', A).
Fill in the blank to specify a window frame that includes the current row and the five preceding rows.
SELECT sales, SUM(sales) OVER (ORDER BY date ROWS BETWEEN [1] PRECEDING AND CURRENT ROW) AS total FROM sales_data;The frame starts 5 rows before and ends at the current row, so '5 PRECEDING' is correct.
Fill all three blanks to create a window frame that starts three rows before, ends two rows after the current row, and orders by the 'transaction_date' column.
SELECT sales, SUM(sales) OVER (ORDER BY [1] ROWS BETWEEN [2] PRECEDING AND [3] FOLLOWING) AS total_sales FROM sales_data;
The ORDER BY column is 'transaction_date', the frame starts 3 rows before and ends 2 rows after the current row.