SQL Trigonometric Functions
The SQL ACOS() and COS() functions
Both SQL ACOS() and COS() functions are trigonometric. The SQL ACOS() function returns the angle, in radians, whose cosine is the specified float expression (the valid ranges for ACOS() arguments are from -1 through 1). The SQL COS() function returns the cosine of the specified angle, in radians, based on the float expression. Here is an example:
SELECT ACOS(-0.9) as acos_of_0_9,
COS(1.00) as cos_of_1
And the output is
acos_of_0_9 cos_of_1
--------------- ----------------
2.6905658417935 0.54030230586814
The SQL ASIN() and SIN() functions
Both SQL ASIN() and SIN() functions trigonometric which use a float expression as an input argument. The SQL ASIN() function calculates the angle, measured in radians, whose sine is the specified float expression input argument.(the valid ranges for ASIN() input argument are from -1 through 1). The SIN() function calculates the trigonometric sine value of the angle, measured in radians, as a float expression input argument. here is an example of SQL ASIN() and SIN() functions:
SELECT ASIN(0) AS arcsin_of_0,
SIN(PI()/2) AS sin_of_pi_2
And the output is
arcsin_of_0 sin_of_pi_2
----------- -----------
0 1
The SQL ATAN(), ATN2(), TAN(), and COT() functions
The SQL ATAN(), ATN2(), TAN(), and COT() functions are mathematical functions and their meanings are listed as folows:
- The SQL ATAN() function returns the measurement of the angle, in radians, whose tangent is the specified float expression.
- The SQL ATN2() function returns the angle, in radians, for an angle whose tangent is between the two specified float expressions.
- The SQL TAN() function returns the trigonometric tangent of the specified float expression.
- The SQL COT() function returns the trigonometric cotangent of the specified angle, in radians, indicated in the specified float expression.
The SQL DEGREE() and RADIANS() functions
The SQL DEGREES() function returns a numeric expression, the measurement of an angle, in degrees, from the measurement in radians of the angle, while the SQL RADIANS() function calculates the angle in radians from the specified measurement in degrees of the angle. Here is a example query:
SELECT RADIANS(180) as radian_of_180,
DEGREES(PI()) as degree_of_pi
And output is:
radian_of_180 degree_of_pi --------------- ------------ 3.1415926535898 180