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_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 |
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_day | dau | new_users | absolute_gap |
|---|---|---|---|
| 2024-04-01 | 1240 | 180 | 1060 |
| 2024-04-02 | 1315 | 205 | 1110 |
| 2024-04-03 | 1288 | 164 | 1124 |
| 2024-04-04 | 1392 | 221 | 1171 |
ABS returns the real magnitude between DAU and new users for each date.
Sign up free to try it on a real business scenario