In order to get log and natural logarithm of the column in postgresql we use LOG() function and LN() Function Let’s see how to
- Get LOG of the column in postgresql – log to the base 10 , Log to base 2
- Get Natural Logarithm of column in postgresql
Get LOG() in Postgresql:
LOG function in posgresql gets the Log to the base 10
SELECT LOG(100) AS "Logarithmic_val";
So log to the base 10 will be
Log to the base 2 will be
SELECT LOG(2,100) AS " Log_to_base_2_val";
So log to the base 2 will be
Get LN() in Postgresql:
Get natural logarithm – LN() function in posgresql.
SELECT LN(100) AS "Natural_log"
Get the Logarithm of column in Postgresql
We will be using basket table.
SELECT *,LOG(price) AS "Log_to_base10", LOG(2,price) AS Log_to_base2 FROM basket;
In the above code we have shown, How to calculate log to base 10 and log to base 2 of price. So the resultant table will be
Get Natural logarithm of column in Postgresql – LN()
SELECT *,LN(price) AS "Natural_Log" FROM basket;
In the above code we have shown, How to calculate natural logarithm of column. So the resultant table will be