Loading…
Build an efficient daily KPI summary query — the kind of query that powers real dashboards.
You've used LAG(column) to get the previous row. You can also specify an offset:
LAG(total_sessions, 7) OVER(ORDER BY date)
-- Gets the value from 7 rows (days) ago!
growth_pct = (today - same_day_last_week) / same_day_last_week × 100
The first 7 days won't have a previous week value → they'll be NULL. Filter them out with WHERE.
Downloading SQL engine… (one-time)
This runs entirely in your browser and is cached for next time.