# SQL LOG10 Function

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

```SELECT LOG10 (Float_Expression)
FROM [Source]```

## SQL LOG10 Function Example 1

The LOG10 Function is used 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 LOG 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]```

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

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

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

```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 Function Example 2

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

```SELECT [EnglishProductName]
,[Color]
,[StandardCost]
,[ListPrice]
,[DealerPrice]
,LOG10([DealerPrice]) AS [Dealer_Log result]
,[SalesAmount]
,[TaxAmt]
,LOG10([TaxAmt]) AS [Tax_Log result]
FROM [SQL Tutorial].[dbo].[Prod Sales]```
Categories SQL