Get Log and Natural Logarithm of the column in postgresql

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

Get Log and natural log of the column in postgresql 1

 

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 Log and natural log of the column in postgresql 2

 

Get LN() in Postgresql:

Get natural logarithm – LN() function in posgresql.


SELECT LN(100) AS "Natural_log"

Get Log and natural log of the column in postgresql 3

 

 

Get the Logarithm of column in Postgresql

We will be using basket table.

Get Log and natural log of the column in postgresql 4

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 Log and natural log of the column in postgresql 5

 

 

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

Get Log and natural log of the column in postgresql 6