DEGREES() Function in MySQL
Last Updated :
01 Oct, 2020
DEGREES() function in MySQL is used to convert the radian values into degrees. The formula for converting radian to degree is :
π radian = 180 degrees
Syntax :
DEGREES(X)
Parameter : This method accepts only one parameter.
X : The radian value which we convert to degrees.
Returns : It returns equivalent radian values into degrees.
Example-1 : Finding Degree Value for 0 radian using DEGREES Function.
SELECT DEGREES(0) AS Degree_Value;
Output :
Example-2 : Finding Degree Value for 3.141592653589793 radian using DEGREES Function.
SELECT DEGREES(3.141592653589793) AS Degree_Value;
Output :
Example-3 : Finding Degree Value for -1.5707963267948966 radian using DEGREES Function.
SELECT DEGREES(-1.5707963267948966 ) AS Degree_Value;
Output :
Example-4 : Using RADIANS Function to convert degrees from radian for a column data. To demonstrate, let us create a table named Polygon.
CREATE TABLE Polygon (
Shape VARCHAR(100) NOT NULL,
Sides INT NOT NULL,
Sum_of_Interior_Angles DECIMAL(10, 2) NOT NULL,
Each_Angle DECIMAL(10, 2) NOT NULL,
PRIMARY KEY(Sides)
);
Now, insert some data to the Polygon table -
INSERT INTO
Polygon(Shape, Sides, Sum_of_Interior_Angles, Each_Angle)
VALUES
('Triangle', 3, 3.141592653589793, 1.0471975511965976),
('Quadrilateral', 4, 6.283185307179586, 1.5707963267948966),
('Pentagon', 5, 9.42477796076938, 1.8849555921538759),
('Hexagon', 6, 12.566370614359172, 2.0943951023931953),
('Heptagon', 7, 15.707963267948966, 2.2439698192891093),
('Octagon', 8, 18.84955592153876, 2.356194490192345),
('Nonagon', 9, 21.991148575128552, 2.443460952792061),
('Decagon', 10, 25.132741228718345, 2.5132741228718345);
So, the Polygon Table is -
SELECT * FROM Polygon;
Shape |
Sides |
Sum_of_Interior_Angles |
Each_Angle |
Triangle |
3 |
3.14159265358979300000 |
1.0471975511965976 |
Quadrilateral |
4 |
6.28318530717958600000 |
1.5707963267948966 |
Pentagon |
5 |
9.42477796076938 |
1.8849555921538759 |
Hexagon |
6 |
12.566370614359172 |
2.0943951023931953 |
Heptagon |
7 |
15.707963267948966 |
2.2439698192891093 |
Octagon |
8 |
18.84955592153876 |
2.356194490192345 |
Nonagon |
9 |
21.991148575128552 |
2.443460952792061 |
Decagon |
10 |
25.132741228718345 |
2.5132741228718345 |
We can see that sum of interior angles and each angle of the polygon are given in radian. Now we will convert these into degrees with the help of DEGREES Function.
SELECT Shape, Sides,
DEGREES(Sum_of_Interior_Angles) AS Sum_of_Interior_Angles_InDegree,
DEGREES(Each_Angle) AS Each_Angle_InDegree
FROM Polygon;
Output :
Shape |
Sides |
Sum_of_Interior_Angles_InDegree |
Each_Angle_InDegree |
Triangle |
3 |
180 |
59.99999999999999 |
Quadrilateral |
4 |
360 |
90 |
Pentagon |
5 |
540 |
108 |
Hexagon |
6 |
720 |
119.99999999999999 |
Heptagon |
7 |
900 |
128.57 |
Octagon |
8 |
1080 |
135 |
Nonagon |
9 |
1260 |
140 |
Decagon |
10 |
1440 |
144 |
So, here the sum of all interior angle, and each angle are converted to equivalent degree value.
Similar Reads
DIV() Function in MySQL
DIV() function : This function in MySQL is used to return a quotient (integer) value when integer division is done. For example, when 7 is divided by 3, then 2 will be returned. Syntax : SELECT x DIV y; Parameter : This method accepts two parameters as given below as follows. x - Specified dividend
1 min read
EXP() Function in MySQL
EXP() function in MySQL is used to returns E raised to the power of a specified number. Here E(2.718281...) is the base of the natural logarithm. Syntax : EXP(X) Parameter : This method accepts one parameter as mentioned above in the syntax and described below : X â A specified number which will be
2 min read
DAY() Function in MySQL
DAY() function : This function in MySQL is used to return the day of the month for a specified date (a number from 1 to 31). This function equals the DAYOFMONTH() function. Syntax : DAY(date) Parameter : This method accepts a parameter which is illustrated below : date : Specified date to extract th
1 min read
ELT() Function in MySQL
In this article, we are going to cover ELT function with examples. In ELT function, number field will state that how many strings will be there. ELT function in MySQL is used to returns the string which is at index number specified in the argument list. In this function there is number field and str
1 min read
AVG() Function in MySQL
AVG() function : This function in MySQL is used to return the average value of the specified expression. Features : This function is used to find the average value of the specified expression.This function comes under Numeric Functions.This function accepts only one parameter namely expression.This
2 min read
DAYOFYEAR() Function in MySQL
DAYOFYEAR() function: This function in MySQL is used to return the day of the year for a specified date (a number from 1 to 366). Syntax : DAYOFYEAR(date) Parameter : This method accepts a parameter which is illustrated below: date: Specified date to return the day of the year from Returns : It retu
1 min read
CEILING() Function in MySQL
CEILING() function :This function in MySQL is used to return the smallest integer value that is greater than or equal to a specified number. For example, if the specified number is 4.6, this function will return the integer value of 5 that is greater than 4.6 or if a specified number is 5, this func
2 min read
EXTRACT() Function in MySQL
The EXTRACT() function in MySQL is a versatile tool used for retrieving specific components of date Whether we need the year, month, day or even the hour or minute. This function simplifies date manipulation and makes queries involving date and time data more efficient and easier to understand. In t
3 min read
CURTIME() function in MySQL
CURTIME() function in MySQL is used to check the current time. It returns the current time as a value in âhh:mm:ssâ or 'hhmmss' format, depending on whether the function is used in a string or numeric context. Syntax : CURTIME(fsp) Parameters : This method accepts only one parameter. fsp - It specif
2 min read
ADDDATE() function in MySQL
The ADDDATE() function in MySQL is a powerful tool for adding specific time intervals to date or datetime values. It simplifies data manipulation by allowing us to easily calculate future or adjusted dates based on a given starting point. In this article, we will learn about the ADDDATE() function i
3 min read