DuckDB has a fsum()
function that can be used instead of the regular sum()
function in order to get more accurate results. fsum()
calculates the sum using a floating point summation method known as Kahan summation (or compensated summation).
This method helps reduce the accumulation of rounding errors that can occur when summing many floating point numbers when using the regular sum
() function.