SUM returns the total of one or more numbers. It can take an arbitrary number of optional arguments.
Function category: Statistical
SUM(arg1, [arg2, ...])
Optional. Same requirements as
Let's say we're given a response with the following vehicle information:
If we want an create an endpoint with an attribute called
horsepower_plus_weight, we can access and sum the values of the respective keys of the
vehicle_info object using this function.
# Sum two diferent valuesSUM(vehicle_info.horsepower, vehicle_info.weight_kg)# Returns 2180
If we want to find the sum of multiples of the same value, use the following function.
# Sum two identical valuesSUM(vehicle_info.horsepower, vehicle_info.horsepower)# Returns 920
If we want to find the value of a single key, which in this case is the number fo cylinders, use the following function.
# Sum of a single valueSUM(vehicle_info.cylinders)# Returns 8
If we want to find the value of a set of four integers and one reference, use the following function.
# Sum of integers and a valueSUM(20, 20, 25, 25, vehicle_info.horsepower)# 550