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_IDProduct_NameProduct_QuantityPurchasing_PriceSelling_PriceRelease_DateProduct_Rating
0.1P10.2500.5NULL2022-04-30NULL
0.2P40.5000.45-0.82022-01-280.25
0.3P20.3500.850.2502022-02-180.15
0.4P70.8500.355NULL2021-12-250.45
0.5P60.9000.5-0.5002021-10-15NULL
0.6P80.7500.110-0.952022-01-28-0.9
0.7P100.2500.5500.2582022-04-11NULL

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_IDATAN_Value_of_Product_ID
0.19.966865
0.20.1973955
0.30.291456
0.40.380506
0.50.463647
0.60.540419
0.70.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_PriceATAN_Value_of_PurchasingPrice
0.50.463647
0.450.42285
0.850.704494
0.3550.341122
0.50.463647
0.1100.109559
0.5500.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_RatingATAN_Value_of_productrating
NULL-
0.250.244978
0.150.148889
0.450.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_PriceATAN_Value_of_SellingPrice
NULL-
-0.80.674740
0.250-0.244978
NULL-
-0.500-0.463647
-0.95-0.759762
0.2580.252493





Latest Courses