Hitachi

Hitachi Advanced Database SQL Reference


8.3.3 LOG

Given a base and antilogarithm, returns its logarithm.

Organization of this subsection

(1) Specification format

scalar-function-LOG ::= LOG(base,target-data)
 
  base ::= value-expression
  target-data ::= value-expression

(2) Explanation of specification format

base:

Specifies the base of the logarithm.

The following rules apply:

  • Specify the base in the form of a value expression. For details about value expressions, see 7.20 Value expression.

  • Specify numeric data for the base. For details about numeric data, see (1) Numeric data in 6.2.1 List of data types.

  • You cannot specify a value less than or equal to 0 for the base.

  • If you specify 1 for the base, a divide-by-zero error is generated.

  • You cannot specify a dynamic parameter by itself for the base.

target-data:

Specify the target data (antilogarithm).

The following rules apply:

  • Specify the target data in the form of a value expression. For details about value expressions, see 7.20 Value expression.

  • Specify numeric data for the target data. For details about numeric data, see (1) Numeric data in 6.2.1 List of data types.

  • You cannot specify a value less than or equal to 0 for the target data.

  • You cannot specify a dynamic parameter by itself for the target data.

(3) Rules

  1. The data type of the execution result is the DOUBLE PRECISION type.

  2. The NOT NULL constraint does not apply to the value of the execution result (the null value is allowed).

  3. If either the base or target data has a null value, the execution result will be a null value.

  4. The execution result of LOG(base,target-data) is equivalent to LN(target-data)/LN(base).

(4) Examples

Example 1:

Determine the common logarithm of the value of column C1 in table T1.

SELECT LOG(10,"C1") FROM "T1"

[Figure]

Example 2:

Determine the logarithm of the value of column C2 in table T1, using the value of column C1 as the base.

SELECT LOG("C1","C2") FROM "T1"

[Figure]