SQL Growth Rate
The same percentage-change formula, applied consistently across an entire time series — the metric most business dashboards actually mean by 'growth rate.'
What & Why
Growth rate compares the current growth.daily_active_users.dau value with the previous day's value: (current_dau - previous_dau) / previous_dau * 100.
LAG(dau) OVER (ORDER BY date_day) supplies the previous day's DAU without collapsing daily rows. NULLIF(previous_dau, 0) protects the denominator.
See How It Works
Growth wants daily active-user growth compared with the previous day.
| date_day | dau | new_users | returning_users |
|---|---|---|---|
| 2024-04-01 | 1240 | 180 | 1060 |
| 2024-04-02 | 1315 | 205 | 1110 |
| 2024-04-03 | 1288 | 164 | 1124 |
| 2024-04-04 | 1392 | 221 | 1171 |
SELECT
date_day,
dau,
LAG(dau) OVER (ORDER BY date_day) AS previous_dau,
ROUND(100.0 * (dau - LAG(dau) OVER (ORDER BY date_day)) / NULLIF(LAG(dau) OVER (ORDER BY date_day), 0), 2) AS growth_rate
FROM growth.daily_active_users
ORDER BY date_day;| date_day | dau | previous_dau | growth_rate |
|---|---|---|---|
| 2024-04-01 | 1240 | NULL | NULL |
| 2024-04-02 | 1315 | 1240 | 6.05 |
| 2024-04-03 | 1288 | 1315 | -2.05 |
| 2024-04-04 | 1392 | 1288 | 8.07 |
LAG supplies the actual previous-day DAU before each percentage change is calculated.
Practice this concept
Growth wants daily active-user growth compared with the previous day.
growthPrefix tables with growth.table_name.
date_daydauprevious_daugrowth_rategrowth.daily_active_users| Column | Type |
|---|---|
| date_day | date |
| dau | integer |
| new_users | integer |
| returning_users | integer |
| internal_tracking_code | text |
Sign up free to try it on a real business scenario