Access the value of a column from a preceding or following row.
How to Compare current day's sales with the previous or next day.
=====================================
SELECT product_id,category,sales,
LAG(sales) OVER (PARTITION BY category ORDER BY date) AS previous_day_sales,
LEAD(sales) OVER (PARTITION BY category ORDER BY date) AS next_day_sales
FROM `logical-cubist-429017-g8.testdataset.sales_table`
=================================================
bigquery,lag function,google bigquery,sql window functions,window function,bigquery functions,lag,sql window function,lag and lead in window functions,analytic function,bigquery sql date functions,sql lag function,window functions sql,google bigquery tutorial,lag() function,window functions lag,window function in sql,sql lag() function
Download
0 formats
No download links available.
Window Function in Google BigQuery (LAG/LEAD) Demo | NatokHD