SQLite LOG10() Function
The SQLite LOG10() function returns the base-10 logarithm of a given number. In special cases it returns the following:
- If the number is less than or equal to 0, then NULL is returned.
Syntax
LOG10(number)
Parameters
number |
Required. Specify the number. Must be greater than 0. |
Return Value
Returns the base-10 logarithm of a given number.
Example 1:
The example below shows the usage of LOG10() function.
SELECT LOG10(1); Result: 0.0 SELECT LOG10(2); Result: 0.301029995663981 SELECT LOG10(3); Result: 0.477121254719662 SELECT LOG10(10); Result: 1.0 SELECT LOG10(15); Result: 1.17609125905568 SELECT LOG10(0); Result: NULL
Example 2:
Consider a database table called Sample with the following records:
Data | x |
---|---|
Data 1 | 0.5 |
Data 2 | 1 |
Data 3 | 5 |
Data 4 | 10 |
Data 5 | 50 |
The statement given below can be used to calculate the base-10 logarithm of column x.
SELECT *, LOG10(x) AS LOG10_Value FROM Sample;
This will produce the result as shown below:
Data | x | LOG10_Value |
---|---|---|
Data 1 | 0.5 | -0.301029995663981 |
Data 2 | 1 | 0.0 |
Data 3 | 5 | 0.698970004336019 |
Data 4 | 10 | 1.0 |
Data 5 | 50 | 1.69897000433602 |
❮ SQLite Functions