What is TAN() Function in SQL

SQL TAN() is a built-in function that is used for finding the tangent of the specified angle(in radians) in the defined float expression. The mathematical formula for this function is TAN(x) = Length of the Opposite Side / Length of the Adjacent Side.

SQL TAN() function returns the tangent of a number.

SQL TAN() method calculates the Tangent value for the given angle.

Syntax

SELECT TAN (float_expression);

Parameters

Float_expression: An expression of float or any other type which is implicitly converted to float whose tangent value is to be retrieved.

Examples

Query 1

SELECT TAN (1);

Output

1.5574077246549

Explanation

Here, the tangent value is returned.

Query 2

SELECT TAN (3);

Output

-0.142546543074278

Explanation

Here, the tangent value is returned.

Query 3

SELECT TAN (1.3);

Output

3.6021024479679786

Explanation

Here, the tangent value is returned.

Query 4

SELECT TAN (2.5 + 0.3);

Output

-0.35552983165117608

Explanation

Here, the cotangent value of the arithmetic expression is returned.

Query 5

SELECT PI () 'PI', TAN (PI ()) 'Tangent of PI';

Output

PI Tangent of PI
3.14159265358979 -1.22464679914735E-16

Explanation

In this PI function was passed as an argument to the TAN function.

Conclusion

The SQL TAN() method calculates the tangent of an input argument.

In math, given the ABC triangle, the tan(A) is defined as the ratio between the side opposite to the A (a) and the side adjacent to the A (b) as follows.

tan A = a / b

For the inverse of a TAN() function, see the ATAN() function.

That’s it.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.