Tutorial Gateway

  • C Language
  • Java
  • R
  • SQL
  • MySQL
  • Python
  • BI Tools
    • Informatica
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • QlikView
  • Js

SQL LOG10 Function

by suresh

The SQL LOG10 function is one of the Mathematical function which is used to calculate the base 10 logarithmic value of the given float value.

In this article we will show you, How to use this SQL Server LOG10 function with example.

SQL LOG10 Function Syntax

The basic syntax of the LOG10 Function is as shown below:

SELECT LOG10 (Float_Expression)
FROM [Source]

SQL LOG10 Function Example 1

The LOG10 Function is used to calculate the logarithmic value of given float value with user specified base value.

In this example, We are going to check the same with different data and display the output

T-SQL CODE

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]

OUTPUT

SQL LOG10 Function 1

ANALYSIS

Within this LOG10 Function example query, Below lines of code is used to declare float variable and assigning the random value.

DECLARE @i float
SET @i = 10

Next, we are calculating the logarithmic value of @i base 10. We also assigned new name to the result as ‘LOG10 Result 1’ using SQL ALIAS Column.

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

In the below statement, We used LOG10 function directly on the 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]

SQL LOG10 Function Example 2

In this example, We are going to calculate the base 10 logarithmic value of all the records present in the [DealerPrice] and [Tax Amount] using LOG10 Function.

T-SQL CODE

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]

OUTPUT

SQL LOG10 Function 2

Thank You for Visiting Our Blog

Placed Under: SQL

Stay in Touch!

Sign Up to receive Email updates on Latest Tutorials

  • C Programs
  • Java Programs
  • SQL FAQ’s
  • Python Programs
  • SSIS
  • Tableau
  • JavaScript

Copyright © 2019 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy