Home > T-SQL > SQL SERVER – Logarithm Log10() – SQL Math Functions @SQLSERVER

SQL SERVER – Logarithm Log10() – SQL Math Functions @SQLSERVER


Merry Christmas  to my readers.

Log10() function returns the base-10 logarithm of the specified float expression. The return type of this function is a float value.

In the previous blog, I talked about log() function, it has as optional parameter base. But log1o() does not have optional parameter for base. Because, the base of the function is always 10 as given in the function name.

The logarithm to base 10 is called the common logarithm. For example, the logarithm of 1000 to base 10 is 3 = 10 x 10 x 10 = 103. – Wikipedia

log10(1000) = 3

Example

select log10(10000)
Output: 4
 
select log10(1500)
Output: 3.17609125905568
 
select power(10, 3.17609125905568)
Output: 1499
 
select power(10, log10(1500))
Output: 1500
 

As we can see from the last example, LOG10 and POWER functions are used to get the float expression value. Happy programming.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: