Skip to content
Advertisement

Distance between two integer values

is there a simple method to calculate the distance between two values e.g. 10 and 30 which will result to 20. Currently I do it as follows:

CASE
  WHEN value_1 < value_2 THEN 
    value_2 - value_1 
  ELSE value_1 - value_2
END AS difference_predicted_days

Advertisement

Answer

The Absolute value function does the trick.

ABS(value1 - value2)

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement