Related Articles

# SIGN (), SQRT () and SUM () Function in MariaDB

• Last Updated : 21 Jun, 2021

1. SIGN Function :
In MariaDB, The SIGN Function is used to returns a value indicating the sign of a number. In this function, a number will be passed and this function will return if the number will be less than 0, This function will return 0 if the number will be equal to 0 and this function will return 1 if the number will be greater than 0.

Syntax :

Attention reader! Don’t stop learning now. Learn SQL for interviews using SQL Course  by GeeksforGeeks.

`SIGN( number )`

Example-1:

`SELECT SIGN(509);`

Output :

`1`

Example-2:

`SELECT SIGN(0);`

Output :

`0`

Example-3:

`SELECT SIGN(-346);`

Output :

`-1`

2. SQRT Function :
In MariaDB, The SQRT Function is used to return the square root of a number. In the SQRT function, one parameter value will be passed and then the function will return the square root of that input given or you can say a number you have given as a parameter value. The number must be positive or 0. Otherwise, it will return NULL for the negative values.

Syntax :

`SQRT( number )`

Example-1:

`SELECT SQRT(121);`

Output :

`11`

Example-2:

`SELECT SQRT(0);`

Output :

`0`

Example-3:

`SELECT SQRT(-64);`

Output :

`NULL`

3. SUM Function :
In MariaDB, The SUM Function is used to return sum of the set of values. In this function, the set of value is passed as a parameter and it will return the sum. If in the entries the null value comes then the sum value ignores them. This works similarly to sum function in the python.

Syntax :

`Sum(expression)`

Sample Database :
Table Name -IPL

Example-1:

```SELECT Sum(SCORE) AS Total
From IPL;```

Output :

Example-2:

```SELECT Sum(SCORE) AS Total
From IPL
WHERE SCORE<200;```

Output :

Example-3:

```SELECT Sum(SCORE) AS Total
From IPL
WHERE SCORE>200;```

Output :

My Personal Notes arrow_drop_up