SQL LOG10 Function

The SQL Server LOG10 function is a Mathematical function that calculates the base 10 logarithmic value of the given float value and its syntax is

SELECT LOG10 (Float_Expression)
FROM [Source]

SQL LOG10 Function Example

The LOG10 Function is useful to calculate the logarithmic value of a given float value with the user-specified base value. In this example, We are going to check the same with different data and display the output.

DECLARE @i float
SET @i = 10

SELECT LOG10(@i)AS [LOG10 Result 1]

-- Calculating it directly
SELECT LOG10(1) AS [LOG10 Result 2]

SELECT LOG10(62.9876) AS [LOG Result 3]

SELECT LOG10(120.85 + 213.17 - 220.50 + 15.09) AS [LOG10 Result 4]
LOG10 Example 1

Within this SQL Server LOG10 Function example query, we are calculating the logarithmic value of @i base 10.

Next, we used the function directly on the SQL Server float values.

LOG10 Example 2

Here, We will calculate the base 10 logarithmic value of all the records present in the [DealerPrice] and [Tax Amount] using the LOG10 Mathematical function.

SELECT [EnglishProductName]
      ,LOG10([DealerPrice]) AS [Dealer_Log result]
      ,LOG10([TaxAmt]) AS [Tax_Log result]
  FROM [Prod Sales]
SQL LOG10 Function 2
Categories SQL