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

BUSINESS QUESTION

Growth wants daily active-user growth compared with the previous day.

date_daydaunew_usersreturning_users
2024-04-0112401801060
2024-04-0213152051110
2024-04-0312881641124
2024-04-0413922211171
EXAMPLE QUERY
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;
RESULT — exact output from the displayed Queryflo rows
date_daydauprevious_daugrowth_rate
2024-04-011240NULLNULL
2024-04-02131512406.05
2024-04-0312881315-2.05
2024-04-04139212888.07

LAG supplies the actual previous-day DAU before each percentage change is calculated.

Now You Try

Practice this concept

Growth wants daily active-user growth compared with the previous day.

Available schema
growth

Prefix tables with growth.table_name.

date_daydauprevious_daugrowth_rate
growth.daily_active_users
ColumnType
date_daydate
dauinteger
new_usersinteger
returning_usersinteger
internal_tracking_codetext
query.sql
Intermediate business practice

Sign up free to try it on a real business scenario