w3resource

PostgreSQL LOG() function

LOG() function

The PostgreSQL log() function is used to return the base 10 logarithm of a given number or logarithm of a number for a particular base, as specified in the argument.

Uses of LOG() Function
  • Base 10 Logarithms: To calculate the base 10 logarithm of a number.

  • Custom Base Logarithms: To compute logarithms for any specified base.

  • Mathematical Calculations: Useful in various mathematical formulas involving logarithms.

  • Scientific and Engineering Applications: Employed in scientific and engineering computations that require logarithmic functions.

  • Data Analysis: To transform data using logarithmic scales in statistical and data analysis tasks.

Syntax:

log()

PostgreSQL Version: 9.3

Pictorial presentation of PostgreSQL LOG() function

pictorial presentation of PostgreSQL LOG() function

Example 1: PostgreSQL LOG() function

Code:

SELECT LOG(200.0) AS "Base 10 Logarithm";

Sample Output:

 Base 10 Logarithm
--------------------
 2.3010299956639812
(1 row)

Example 2: PostgreSQL LOG() function

Code:

SELECT LOG(2.0,16) AS "Base 2 Logarithm";

Sample Output:

  Base 2 Logarithm
--------------------
 4.0000000000000000
(1 row)

Previous: LN function
Next: MOD function



Follow us on Facebook and Twitter for latest update.