RADIANS(), RAND() and ROUND() Function in MariaDB
1. RADIANS() :
In MariaDB, RADIANS() function is used to return a value in degrees converted to radians. In this function, a number (an angle in degrees) will be passed as a parameter.
180 degrees = π radians
Syntax :
RADIANS(number)
Returns : A value in radians for the angle input in degrees.
Example-1 :
SELECT RADIANS(180);
Output :
3.141592653589793
Example-2 :
SELECT RADIANS(-14.5);
Output :
-0.2530727415391778
Example-3 :
SELECT RADIANS(30);
Output :
0.5235987755982988
2. Rand() :
In MariaDB, RAND() function is used to return a random number or a random number within a range. In this function, the seed will be passed as a parameter. It is optional, it specifies a repeatable sequence of random numbers each time that seed value is provided. If a seed value is given then this function will return a repeatable sequence of random numbers each time using that seed value.
Syntax :
RAND([seed])
Returns : A value between 0 (inclusive) and 1 (exclusive) and if no seed is given then this function will provide a random number.
Example-1 :
SELECT RAND();
Output :
0.3456785735094069
Example-2 :
SELECT RAND(8);
Output :
0.15668530311126755
Example-3 :
SELECT RAND()*(10-1)+1;
Output :
1.564445336986748
3. ROUND() :
In MariaDB, Round() function is used to return a number rounded to a certain number of decimal places. In this function, two parameters will be passed, the first is the number that will be round, and the second will be a number rounded to a certain number of decimal places. The decimal number of places must be positive or negative.
Syntax :
ROUND(number, [decimal_places])
Returns : The rounded off value for the decimal input.
Example-1 :
SELECT ROUND(55.543, 1);
Output :
55.5
Example-2 :
SELECT ROUND(-89.53);
Output :
-89
Example-3:
SELECT ROUND(579.984, 0);
Output :
579
Contact Us