I have a query where I sum the values from a column WHERE the date = yesterday (current_date - 1):
SELECT sum(col) as sumCol
from `project.dataset.table`
where date = date_sub(current_date, interval 1 day)
What I want to achieve is to calculate the difference between the result of the above and the result of the same query for the day before i.e. where date = date_sub(current_date, interval 2 day)
I am not sure how to create this calculation within a query. I can union the above with the same query for the previous day, but obviously that gives me a row for each day rather than calculating sum(col) interval 1 day - interval 2 day?
Any help would be appreciated to point me in the right direction
Thanks