SQL TAN: Calculates Tangent of an Argument

The SQL TAN function 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 / bCode language: SQL (Structured Query Language) (sql)
SQL_trigonometry_triangle

For the inverse of the TAN function, see the ATAN function.

Syntax

The following shows the syntax of the TAN function.

TAN(numeric_expression)Code language: SQL (Structured Query Language) (sql)

Argument

The TAN function accepts a numeric_expression that represents the angle in radians for which the tangent is calculated.

Return

The TAN function returns a floating-point number.

Examples

The following example returns the tangent of π/4, 0, and -π/4.

SELECT TAN(-PI()/4), TAN(0), TAN(PI()/4);
Code language: SQL (Structured Query Language) (sql)
 tan | tan | tan
-----+-----+-----
  -1 |   0 |   1
(1 row)Code language: SQL (Structured Query Language) (sql)

Note that we use PI function to get the π constant

Most database systems support the TAN function with the same behavior.

Was this tutorial helpful ?