ATN2 Function in SQL

The ATN2 is a mathematics function which returns the arc tangent of two specified numbers.

Syntax of ATN2 Function

In the ATN2 syntax, we have to pass two numeric numbers in the function from which we can find the value of arc tangent.

In the Structured Query Language, we can also use the ATN2 function in the SELECT query with the table fields:

In this SELECT query, we have to define the name and fields of that table on which we want to perform the ATN2 function.

Examples of ATN2 function

Example 1: This example returns the arc tangent value of the specified numbers:

Output:

ATN2_value
0.463647609001

Example 2: This example returns the arc tangent value of -0.5 and 2:

Output:

ATN2_value
-0.244978663127

Example 3: This example returns the arc tangent value of 80 and 110:

Output:

ATN2_value
0.628796286415

Example 4: This example returns the arc tangent value of both negative numbers:

Output:

ATN2_value
-2.7172547187517906

Example 5: This example returns the arc tangent value with the combination of number and PI function:

Output:

ATN2_value
0.66577375002835382

Example 6: This example uses the ATN2 function with the SQL table. In this example, we will create the new table through which we will perform the ATN2 function on the numeric fields of the table:

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 ATN2 function with the Vehicle_ID and Vehicle_Quantity columns of the above Vehicle_Details table:

This query shows the arc tangent value of id and quantity of each vehicle.

Output:

Vehicle_IDVehicle_QuantityATN2 value_of_Vehicle_ID_Vehicle_Quantity
1402900.449759
190151.49201
145201.43373
90101.46013
45350.90975
210301.428899
1852900.567844

Query 2: The following SELECT query uses the ATN2 function with the Purchasing_Vehicles and Selling_Vehicles columns of the above Vehicle_Details table:

This query shows the arc tangent value of all purchasing and selling vehicles.

Output:

Purchasing_VehiclesSelling_VehiclesATN2 value_of_Purchasing_Selling
45800.51238
1801800.78539
2702900.74969
360801.35212
45-151.89254
160-601.92956
4504700.76366

Query 3: The following SELECT query uses the ATN2 function with the Purchasing_Vehicles and Vehicle_Quantity columns of the above Vehicle_Details table:

This query shows the arc tangent value of purchasing and quantity of each vehicle.

Output:

Purchasing_VehiclesVehicle_QuantityATN2 value_of_Purchasing_Quantity
452900.153944
180151.48765
270201.49685
360101.54302
45350.90975
160301.38544
4502900.99833

Query 4: The following SELECT query uses the ATN2 function with the and Purchasing_Vehicles and Vehicle_Quantity column of the above Vehicle_Details table:

This query shows the arc tangent value of selling and quantity of each vehicle.

Output:

Selling_VehiclesVehicle_QuantityATN2 value_of_Selling_Quantity
802900.26916
180151.48765
290201.50193
80101.44644
-1535-0.40489
-6030-1.1071
4702901.0179





Latest Courses