Oracle SQL - Function LOG function

Introduction

LOG - Returns base 10 log.

The LOG function requires two arguments.

The first argument is the base of the log, and the second argument is the number that you want to take the log of.

In the following example, we are taking the log of 2, base value.

Demo

SQL>
SQL> drop table my_table;

Table dropped.-- www  .  j a  v  a2 s  .c o  m

SQL> CREATE TABLE my_table (
  2      LINENO NUMBER(2) not null,
  3      VALUE NUMBER(6,2) not null
  4  );
SQL>
SQL> insert into my_table values(1,1.2);
SQL> insert into my_table values(2,123.34);
SQL> insert into my_table values(3,-12.2);
SQL> insert into my_table values(4,100);
SQL> insert into my_table values(5,48);
SQL> insert into my_table values(6,-90);
SQL> insert into my_table values(7,0.19);
SQL> SELECT LOG(value, 2)
  2  FROM my_table ;
ERROR:
ORA-01428: argument '-12.2' is out of range



no rows selected

SQL>

To get the log of 8, base 2, you would type:

Demo

SQL>
SQL> SELECT LOG(2,8)
  2  FROM dual;-- from   ww w.j  a  v a  2s  . c o  m

 LOG(2,8)
---------
 00003.00

SQL>