The SQL COT
function returns the cotangent of an input argument.
In math, given the ABC triangle, the cotangent of an angle (A) is defined as the ratio between the length of the adjacent side (b) to the length of the opposite side (a) as the follownig formula:
cot A = b / a
Code language: SQL (Structured Query Language) (sql)
Syntax
The following statement shows the syntax of the COT
function.
COT(numeric_expression)
Code language: SQL (Structured Query Language) (sql)
Argument
The COT
function accepts a numeric_expression
that represents the angle in radians for which the cotangent is calculated. The numeric_expression
must not evaluate to zero.
Return
The COT
function returns a floating-point number.
Examples
The following example returns the cotangents of π/6 and π/4.
SELECT COT(PI()/6) cot_one_sixth_pi,
COT(PI()/4) cot_one_fourth_pi;
Code language: SQL (Structured Query Language) (sql)
cot_one_sixth_pi | cot_one_fourth_pi
------------------+-------------------
1.73205080756888 | 1
(1 row)
Code language: SQL (Structured Query Language) (sql)
Note that we use the PI
function to get the π constant.
Most database systems support the COT
function with the same behavior.