Javatpoint Logo
Javatpoint Logo

ATAN Function in SQL

The ATAN is a SQL function of mathematics which returns the arc tangent value of the specified number.

Syntax of ATAN Function

In the ATAN syntax, we have to pass that decimal number whose arc tangent value we want to find.

In the Structured Query Language, we can also use the ATAN function with the column of the table as shown in the following block:

In this syntax, we have to define the name and column of that table on which we want to perform the ATAN function.

Examples of ATAN function

Example 1: This example returns the ATAN_Value of the specified number:

Output:

ATAN_Value_of_15
1.50422816

Example 2: This example returns the ATAN_Value of the specified number:

Output:

ATAN_Value_of_2
1.10714

Example 3: This example returns the ATAN_Value representation of 82:

Output:

ATAN_Value_of_8
1.4464412

Example 4: This example uses the ATAN function with the SQL table.

In this example, we will create the new table through which we will perform the ATAN function on the columns:

The following shows the syntax to create the new table in SQL:

The following CREATE statement creates the Product_Details table for storing the price and quantity of products:

The following multiple INSERT queries insert the records of products with their selling and purchasing price into the Product_Details table:

The following SELECT statement displays the inserted records of the above Product_Details table:


Product_ID Product_Name Product_Quantity Purchasing_Price Selling_Price Release_Date Product_Rating
0.1 P1 0.250 0.5 NULL 2022-04-30 NULL
0.2 P4 0.500 0.45 -0.8 2022-01-28 0.25
0.3 P2 0.350 0.85 0.250 2022-02-18 0.15
0.4 P7 0.850 0.355 NULL 2021-12-25 0.45
0.5 P6 0.900 0.5 -0.500 2021-10-15 NULL
0.6 P8 0.750 0.110 -0.95 2022-01-28 -0.9
0.7 P10 0.250 0.550 0.258 2022-04-11 NULL

Query 1: The following SELECT query uses the ATAN function with the Product_Quantity column of the above Product_Details table:

This query shows the ATAN_Value of product id of each product.

Output:

Product_ID ATAN_Value_of_Product_ID
0.1 9.966865
0.2 0.1973955
0.3 0.291456
0.4 0.380506
0.5 0.463647
0.6 0.540419
0.7 0.610725

Query 2: The following SELECT query uses the ATAN function with the Purchasing_Price column of the above Product_Details table:

This query shows the ATAN_Value of purchasing price of each product.

Output:

Purchasing_Price ATAN_Value_of_PurchasingPrice
0.5 0.463647
0.45 0.42285
0.85 0.704494
0.355 0.341122
0.5 0.463647
0.110 0.109559
0.550 0.502843

Query 3: The following SELECT query uses the ATAN function with the Product_Rating column of the above Product_Details table:

This query shows the ATAN_Value of rating of each product from the above table.

Output:

Product_Rating ATAN_Value_of_productrating
NULL -
0.25 0.244978
0.15 0.148889
0.45 0.422853
NULL -
-0.9 -0.732815
NULL -

Query 4: The following SELECT query uses the ATAN function with the and Purchasing_Price and Selling_Price column of the above Product_Details table:

This query shows the ATAN_Value of selling price of each product.

Output:

Selling_Price ATAN_Value_of_SellingPrice
NULL -
-0.8 0.674740
0.250 -0.244978
NULL -
-0.500 -0.463647
-0.95 -0.759762
0.258 0.252493






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA