# 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_ID Vehicle_Name Vehicle_Quantity Purchasing_Vehicles Selling_Vehicles Release_Date Vehicle_Rating
140 P1 290 45 80 2022-04-30 80
190 P4 15 180 180 2022-01-28 90.85
145 P2 20 270 290 2022-02-18 80
90 P7 10 360 80 2021-12-25 180
45 P6 35 45 -15 2021-10-15 80
210 P8 30 160 -60 2022-01-28 95
185 P10 290 450 470 2022-04-11 80

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_ID Vehicle_Quantity ATN2 value_of_Vehicle_ID_Vehicle_Quantity
140 290 0.449759
190 15 1.49201
145 20 1.43373
90 10 1.46013
45 35 0.90975
210 30 1.428899
185 290 0.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:

45 80 0.51238
180 180 0.78539
270 290 0.74969
360 80 1.35212
45 -15 1.89254
160 -60 1.92956
450 470 0.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:

45 290 0.153944
180 15 1.48765
270 20 1.49685
360 10 1.54302
45 35 0.90975
160 30 1.38544
450 290 0.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_Vehicles Vehicle_Quantity ATN2 value_of_Selling_Quantity
80 290 0.26916
180 15 1.48765
290 20 1.50193
80 10 1.44644
-15 35 -0.40489
-60 30 -1.1071
470 290 1.0179