The code `nullif((p.profile_weight_in_grams / 1000.0), 0)` is a function call...
The code nullif((p.profile_weight_in_grams / 1000.0), 0)
is a function call to the nullif()
function with two arguments.
The first argument (p.profile_weight_in_grams / 1000.0)
divides the value of p.profile_weight_in_grams
by 1000, which converts it from grams to kilograms.
The second argument 0
specifies the value that should be returned if the result of the division is zero.
The nullif()
function returns NULL if the first argument is equal to the second argument; otherwise, it returns the first argument. This means that if the result of the division is zero, then this function will return NULL. Otherwise, it will return the result of the division in kilograms.
In summary, this code converts the weight of a profile from grams to kilograms, and returns NULL if the weight is zero.