LOG
Return the base 10 logarithm of a number, or specify the base to use in the first argument and the number in the second argument.
LOG([ base, ] number)
This function returns a double precision or decimal type, depending on the input type.
- base
- A positive number. If
base
is specified, both arguments must be decimal types. If necessary, use explicit casts. - number
- A positive number.
For example:
premdb=# select log(101) from sys.const;
log
------------------
2.00432137378264
(1 row)
premdb=# select log(2,101) from sys.const;
log
--------------------
6.6582114827517947
(1 row)
premdb=# select log(10.1) from sys.const;
log
------------------------
1.00432137378264257428
(1 row)
premdb=# select avg_att, log(2.0, avg_att) from team where avg_att>0 limit 1;
avg_att | log
---------+----------------------------------------
59.944 | 5.905543451471921012831147221451800576
(1 row)
ppremdb=# select avg_att, log(avg_att)::dec(3,2) from team where avg_att>0 limit 1;
avg_att | log
---------+------
59.944 | 1.78
(1 row)
Parent topic:Mathematical Functions