Example
Return the base-10 logarithm of 2:
SELECT LOG10(2);
Definition and Usage
The LOG10() function returns the natural logarithm of a number to base 10.
Note: Also look at the LOG() function.
Syntax
LOG10(number)
Return the base-10 logarithm of 2:
SELECT LOG10(2);
The LOG10() function returns the natural logarithm of a number to base 10.
Note: Also look at the LOG() function.
LOG10(number)
Return the natural logarithm of 2:
SELECT LOG(2);
The LOG() function returns the natural logarithm of a specified number, or the logarithm of the number to the specified base.
From SQL Server 2012, you can also change the base of the logarithm to another value by using the optional base parameter.
Note: Also look at the EXP() function.
LOG(number, base) — Syntax for SQL Server
OR :
LOG(number) — Syntax for Azure SQL Database, Azure SQL Data Warehouse, Parallel Data Warehouse
Return the largest integer value that is equal to or less than 25.75:
SELECT FLOOR(25.75) AS FloorValue;
The FLOOR() function returns the largest integer value that is smaller than or equal to a number.
Tip: Also look at the CEILING() and ROUND() functions.
FLOOR(number)
Return e raised to the power of 1:
SELECT EXP(1);
The EXP() function returns e raised to the power of a specified number.
The constant e (2.718281…), is the base of natural logarithms.
Note: See also the LOG() function.
EXP(number)
Convert a radian value into degrees:
SELECT DEGREES(1.5);
The DEGREES() function converts a value in radians to degrees.
Note: See also the RADIANS() and PI() functions.
DEGREES(number)
Return the cotangent of a number:
SELECT COT(6);
The COT() function returns the cotangent of a number.
COT(number)
Return the cosine of a number:
SELECT COS(2);
The COS() function returns the cosine of a number.
COS(number)
Return the number of products in the “Products” table:
SELECT COUNT(ProductID) AS NumberOfProducts FROM Products;
The COUNT() function returns the number of records returned by a select query.
Note: NULL values are not counted.
COUNT(expression)
Return the smallest integer value that is greater than or equal to a number:
SELECT CEILING(25.75) AS CeilValue;
The CEILING() function returns the smallest integer value that is larger than or equal to a number.
Tip: Also look at the FLOOR() and ROUND() functions.
CEILING(number)
Return the average value for the “Price” column in the “Products” table:
SELECT AVG(Price) AS AveragePrice FROM Products;
The AVG() function returns the average value of an expression.
Note: NULL values are ignored.
AVG(expression)