LOG
Returns the base-10 logarithm of a number or its logarithm to the given base.
PostgreSQL 17.9
LOG([base, ]num)- [ ]optional part
- base
- Logarithm base, 10 by defaultnumericOptional
- num
- Number to take the logarithm ofnumeric | double precision
Return value
A number of the same type as num, numeric with base; an error if num ≤ 0, base ≤ 0 or base = 1
Examples
Logarithm to base 2
PostgreSQL 17.9
SELECT LOG(2, 8);Base-10 logarithm
PostgreSQL 17.9
SELECT LOG(100);Details
The natural logarithm is computed by LN. In MySQL LOG(num) with one argument is the natural logarithm, while here it is the base-10 logarithm, like LOG10.