DEGREES Function in SQL

The 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 Function

Syntax1: 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 Function

Example 1: This example returns the Degree value of the specified number:

Output:

Degreevalue_of_360
20626.5

Example 2: This example returns the Degree value of the specified number:

Output:

Degreevalue_of_180
10313.2

Example 3: This example returns the Degree value of 90 radians:

Output:

Degreevalue_of_90
5156.62

Example 4: This example returns the Degree value of -45 radian:

Output:

Degreevalue_of_-45
-2578.31

Example 5: This example returns the Degree value of the given expression:

Output:

Degreevalue_of_Expression
3437.75

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:


Vehicle_IDVehicle_NameVehicle_QuantityPurchasing_VehiclesSelling_VehiclesRelease_DateVehicle_Rating
140P129045802022-04-3080
190P4151801802022-01-2890.85
145P2202702902022-02-1880
90P710360802021-12-25180
45P63545-152021-10-1580
210P830160-602022-01-2895
185P102904504702022-04-1180

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:

Vehicle_IDDegree value_of_Vehicle_ID
1408021.41
19010886.2
1458307.89
905156.62
452578.31
21012032.1
18510599.7

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:

Purchasing_VehiclesDegree value_of_PurchasingVehicles
452578.31
18010313.2
27015469.9
36020626.5
452578.31
1609167.32
45025783.1

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:

Vehicle_RatingDegree value_of_vehiclerating
804583.66
90.855205.321
804583.66
18010313.2
804583.66
955443.1
804583.66

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:

Selling_VehiclesDegree value_of_SellingVehicles
804583.66
18010313.2
29016615.8
804583.66
-15-859.437
-60-3437.75
47026929





Latest Courses