# MySQL Numeric or Mathematical Function Part4

LN Function:- LN Function is used for returning the natural logarithm of a given number. If the number will be zero or less than zero then it will return NULL.

The EXP() is the opposite of this LN().

Syntax:- LN(number)

For Example:-

SELECT LN(5);

Output:- 1.6094379124341003

LOG Function:- LOG Function is used for returning the logarithm of a given specified base number. If the number will be less than or equal to zero then it will return NULL.

Syntax:- LOG(Base Number)

For Example:-

SELECT LOG(5);

Output:- 1.6094379124341003

LOG10 Function:- LOG10 Function is used for returning the logarithm of a given specified base 10 number.

Syntax:- LOG10( Number)

For Example:-

SELECT LOG10(5);

Output:- 0.6989700043360189

LOG2 Function:- LOG2 Function is used for returning the logarithm of a given specified base 2 number.

Syntax:- LOG10( Number)

For Example:-

SELECT LOG2(5);

Output:- 2.321928094887362

MAX Function:- MAX Function is used for returning the maximum value from the given set of values.

Syntax:-MAX(aggregate_expression);

For Example:-

Find the maximum marks obtained by students in chemistry subject.

SELECT MAX(marks) FROM subject WHERE subject_name = “chemistry”;

MIN Function:- MIN Function is used for returning the minimum value from the given set of values.

Syntax:-MIN(aggregate_expression);

For Example:-

Find the minimum marks obtained by students in chemistry subject.

SELECT MIN(marks) FROM subject WHERE subject_name = “chemistry”;

MOD Function:- MOD Function is used for returning reminders of dividends divided by a divisor in a division. If the divisor will be zero then it will return NULL.

Syntax:- If Dividend is D1 and Divisor is D2

MOD(D1, D2) or D1 MOD D2 or D1%D2

Example:-

SELECT MOD(5, 2);

Output:-1

SELECT 20 MOD 3;

Output:- 2

SELECT 68 % 7;

Output:-5

PI Function:- PI Function is used for returning the PI value. This function does not accept any parameter.

Syntax:-PI()

Example:-

SELECT PI:-

Output:- 3.141593

Share with: