Open In App

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

Last Updated : 21 Jun, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

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 : 
 

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 

 

TeamID TEAMNAME SCORE
1 CSK 200
2 MI 210
3 RR 150

Example-1: 
 

SELECT Sum(SCORE) AS Total 
From IPL;

Output : 

 

Total
560

Example-2: 
 

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

Output : 

 

Total
150

Example-3: 
 

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

Output : 

 

Total
210

 


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads