SQL ABS

Returns the absolute value — strips away a negative sign, leaving positive numbers untouched.

What & Why

ABS(n) returns the non-negative version of a number — a positive number is returned unchanged, a negative one has its sign flipped. Useful whenever only the size of a difference matters, not its direction.

See How It Works

BUSINESS QUESTION

Growth wants the absolute gap between DAU and new users for each day.

date_daydaunew_usersreturning_users
2024-04-0112401801060
2024-04-0213152051110
2024-04-0312881641124
2024-04-0413922211171
EXAMPLE QUERY
SELECT
  date_day,
  dau,
  new_users,
  ABS(dau - new_users) AS absolute_gap
FROM growth.daily_active_users
ORDER BY date_day;
RESULT — exact output from the displayed Queryflo rows
date_daydaunew_usersabsolute_gap
2024-04-0112401801060
2024-04-0213152051110
2024-04-0312881641124
2024-04-0413922211171

ABS returns the real magnitude between DAU and new users for each date.

Intermediate business practice

Sign up free to try it on a real business scenario