Example
Return the square root of a number:
SELECT SQRT(64);
Definition and Usage
The SQRT() function returns the square root of a number.
Syntax
SQRT(number)
Return the square root of a number:
SELECT SQRT(64);
The SQRT() function returns the square root of a number.
SQRT(number)
Return the sine of a number:
SELECT SIN(2);
The SIN() function returns the sine of a number.
SIN(number)
Return the sign of a number:
SELECT SIGN(255.5);
The SIGN() function returns the sign of a number.
This function will return one of the following:
SIGN(number)
Round the number to 2 decimal places:
SELECT ROUND(235.415, 2) AS RoundValue;
The ROUND() function rounds a number to a specified number of decimal places.
Tip: Also look at the FLOOR() and CEILING() functions.
ROUND(number, decimals, operation)
Return a random decimal number (no seed value – so it returns a completely random number >= 0 and <1):
SELECT RAND();
The RAND() function returns a random number between 0 (inclusive) and 1 (exclusive).
RAND(seed)
Convert a degree value into radians:
SELECT RADIANS(180);
The RADIANS() function converts a degree value into radians.
RADIANS(number)
Return 4 raised to the second power:
SELECT POWER(4, 2);
The POWER() function returns the value of a number raised to the power of another number.
POWER(a, b)
Return the value of PI:
SELECT PI();
The PI() function returns the value of PI.
Note: Also look at the DEGREES() and RADIANS() functions.
PI()
Find the price of the cheapest product in the “Products” table:
SELECT MIN(Price) AS SmallestPrice FROM Products;
The MIN() function returns the minimum value in a set of values.
Note: Also look at the MAX() function.
MIN(expression)
Find the price of the most expensive product in the “Products” table:
SELECT MAX(Price) AS LargestPrice FROM Products;
The MAX() function returns the maximum value in a set of values.
Note: Also look at the MIN() function.
MAX(expression)