Loading

MySQL Numeric or Mathematical Function Part3

DEGREES Function:- DEGREES Function is used for converting radian value into a degree.

Syntax:- DEGREES(radian value)

For Example:-

SELECT DEGREES(PI()/2);

Output:- 90

SELECT DEGREES(1.57079);

Output:- 89.99963750135457

SELECT ROUND(DEGREES(1.57079));

Output:- 90

DIV Function:- DIV Function is used for returning quotient value after the division of two number dividend and divisor.

Syntax:- SELECT dividend DIV divisor

For Example:-

SELECT 15 DIV 3;

Output:- 5

EXP Function:- EXP Function is used for returning “e” raised to the power of a given number.

Syntax:- EXP(number)

For Example:-

SELECT EXP(10);

Output:- 22026.465794806718

FLOOR Function:- FLOOR Function is used for returning the largest integer value of a given number which will be less than or equal to the given number.

Syntax:- FLOOR(number)

For Example:-

SELECT FLOOR(10.45);

Output:- 10

FORMAT Function:- FORMAT Function is used for returning the formatted numbers of a given number.  It round the number in specified decimal place(#,###,###.##)

Syntax:-FORMATE(number. decimal_place);

There are one optional parameter too “local”, By default mysql uses en_US.

Example:-

SELECT FORMAT(5678.9856, 3);

Output:- 5,678.986

FORMAT_BYTES Function:- FORMAT_BYTES Function is used for  Converting byte count to value with units.

According to MySQL documentation, this function deprecated from MySQL Verson 8.0.16.

Syntax:- FORMAT_BYTES(Byte text);

GeomCollection Function:- GeomCollection Function is a property function in MySQL. GeomCollection Function and  GeometryCollection Function are synonyms. It returns the nth geometry in the GeometryCollection value.

GREATEST Function:- The GREATEST Function is used for returning the greatest value from a given argument. If in a given argument any value will be NULL  then it will return NULL otherwise it will return the greatest value.

Syntax:- GREATEST(a1, a2, a3, a4, …….)

Example:-

SELECT GREATEST(6, 18, 12, 48, 36);

Output:- 48

SELECT GREATEST(“lemon”, “Orange”, “mango”, “pineapple”);

Output:- pineapple

LEAST Function:- The LEAST Function is just the opposite of the GREATEST Function. The LEAST Function is used for returning the least value from a given argument. If in a given argument any value will be NULL  then it will return NULL otherwise it will return the least value.

Syntax:- LEAST(a1, a2, a3, a4, …….)

Example:-

SELECT LEAST (6, 18, 12, 48, 36);

Output:- 6

SELECT LEAST (“lemon”, “Orange”, “mango”, “pineapple”);

Output:- lemon

Share with:


Leave a Reply

Connect with:

z35W7z4v9z8w