DEGREES Function in SQLThe DEGREES is a mathematical function in the Structured Query Language which converts the specified value of radians into degree. This function accepts the angle of radian as argument and returns the equivalent angle in degree. The return type of function is same as the argument type. Syntax of DEGREES FunctionSyntax1: This syntax uses the DEGREES function with the column name of the SQL table: In this SELECT syntax, we have to specify the name of that numeric column on which we want to use DEGREES function. Syntax2: We can also use the DEGREES function with the particular number as shown in the following block: Examples of DEGREES FunctionExample 1: This example returns the Degree value of the specified number: Output:
Example 2: This example returns the Degree value of the specified number: Output:
Example 3: This example returns the Degree value of 90 radians: Output:
Example 4: This example returns the Degree value of -45 radian: Output:
Example 5: This example returns the Degree value of the given expression: Output:
Example 6: This example uses the DEGREES function with the SQL table. In this example, we will create the new table through which we will perform the DEGREES function on the columns: The following shows the syntax to create the new table in SQL: The following CREATE statement creates the Vehicle_Details table for storing the details of purchasing and selling vehicles: The following multiple INSERT queries insert the records of vehicles with their quantity, and number of selling and purchasing vehicles into the Vehicle_Details table: The following SELECT statement displays the inserted records of the above Vehicle_Details table:
Query 1: The following SELECT query uses the DEGREES function with the Vehicle_ID column of the above Vehicle_Details table: This query shows the Degree value of vehicle id of each vehicle. Output:
Query 2: The following SELECT query uses the DEGREES function with the Purchasing_Vehicles column of the above Vehicle_Details table: This query shows the Degree value of purchasing vehicles. Output:
Query 3: The following SELECT query uses the DEGREES function with the Vehicle_Rating column of the above Vehicle_Details table: This query shows the Degree value of rating of each vehicle from the above table. Output:
Query 4: The following SELECT query uses the DEGREES function with the and Purchasing_Vehicles and Selling_Vehicles column of the above Vehicle_Details table: This query shows the Degree value of selling Vehicles of each vehicle. Output:
Next TopicEXP Function in SQL |