If you’re getting an error that reads “ERROR: cannot take logarithm of a negative number” when using either the log()
function or log10()
function in PostgreSQL, it’s probably because you’re passing a negative value to the function.
These functions require a value greater than zero. This is true even for the base argument of the log()
function (the argument that specifies which base to use).
To fix this issue, be sure to pass a value greater than zero to these functions.
Continue reading