Hello @AeroG and welcome to Microsoft Q&A.
As I understand, you wish for help in the process of debugging an arithmetic overflow error.
An arithmetic overflow occurs when the output of an operation is a value bigger than can be stored in the destination data type. This means the data type must be numerically bound -- Integers, Floats, (maybe decimal). Strings and chars have different error message. This error message may also apply to date / datetime.
Given this, the most suspect part of your code is
CAST([tripDistance] AS [real]) AS [tripDistance],
According to (doc link), Real is equivalent to Float(24). There is a bigger version of float, called double, as it is double the size of a standard float. Try float(53)
or double precision
instead of real, and see if the error message goes away.
Please let me know if this helps.