# TAN Function in SQL

The TAN() is a mathematics function which returns the tangent value of the given number in the Structured Query Language.

### Syntax of TAN Function

In this SELECT syntax, we have to pass that numeric number in the function whose tan value we want to find.

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

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

### Examples of TAN function

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

Output:

tan_value_of_1.75
-5.5203799225093304

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

Output:

tan_value_of_45
1.6197751905438615

Example 3: This example returns the tangent value representation of 19:

Output:

tan_value_of_19
0.15158947061240008

Example 4: This example returns the tangent value representation of the numbers from 21 to 30:

Output:

21 22 23 24 25 26 27 28 29 30
-1.527 8.8515 1.5881 -2.1348 -0.133 1.1787 -3.273 -0.2814 0.8871 -6.4053

Example 5: This example uses the TAN function with the SQL table.

In this example, we will create the new table through which we will perform the TAN function on the numeric fields:

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
64 P1 10.250 945 NULL 2022-04-30 NULL
88 P4 15.500 45 75 2022-01-28 5
95 P2 18.250 25 NULL 2022-02-18 4
58 P7 25.250 5 15 2021-12-25 9
26 P6 15.500 50 70 2021-10-15 NULL
85 P8 19.750 110 250 2022-01-28 4
91 P10 10.250 550 835 2022-04-11 NULL

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

This query returns the tangent value of product id of each product from the table.

Output:

Product_ID tan_value_of_Product_ID
64 2.3478603091954366
88 3.5420501339376929E-2
95 0.9357524720632393
58 8.335086
26 1.1787
85 0.17787
91 -0.1065878

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

This query shows the tangent value of purchasing price of each product.

Output:

945 -0.71298
45 1.61977
25 -0.1335
5 -3.30581
50 -0.271900611
110 0.0442860
550 0.224969

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

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

Output:

Product_Rating tan_value_of_productrating
NULL -
5 -3.3808515
4 1.15782
9 -0.452315
NULL -
4 1.15782
NULL -

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

This query shows the tangent value of quantity of each product from the above table.

Output:

Product_Quantity tan_value_of_productquantity
10.250 1.08299
15.500 -0.211014
18.250 -0.6834
25.250 0.117799
15.500 -0.211014
19.750 1.2613
10.250 1.08299