MySQL DEGREES() Function
The MySQL DEGREES() function returns an angle measured in radians to an approx. equivalent angle measured in degrees.
Syntax
DEGREES(x)
Parameters
x |
Required. Specify an angle in radians. |
Return Value
Returns the angle measured in degrees.
Example 1:
The example below shows the usage of DEGREES() function.
mysql> SELECT DEGREES(0); Result: 0 mysql> SELECT DEGREES(1); Result: 57.29577951308232 mysql> SELECT DEGREES(2); Result: 114.59155902616465 mysql> SELECT DEGREES(3); Result: 171.88733853924697 mysql> SELECT DEGREES(PI()/3); Result: 59.99999999999999 mysql> SELECT DEGREES(PI()/2); Result: 90 mysql> SELECT DEGREES(PI()); Result: 180
Example 2:
Consider a database table called Sample with the following records:
Data | x |
---|---|
Data 1 | 0 |
Data 2 | 1 |
Data 3 | 2 |
Data 4 | 3 |
Data 5 | 4 |
The statement given below can be used to convert the records of column x (containing values expressed in radians) into degrees.
SELECT *, DEGREES(x) AS DEGREES_Value FROM Sample;
This will produce the result as shown below:
Data | x | DEGREES_Value |
---|---|---|
Data 1 | 0 | 0 |
Data 2 | 1 | 57.29577951308232 |
Data 3 | 2 | 114.59155902616465 |
Data 4 | 3 | 171.88733853924697 |
Data 5 | 4 | 229.1831180523293 |
❮ MySQL Functions