SQL SIN: Calculates Sine of an Argument

The SQL SIN function calculates the sine of an input argument.

In math, given the ABC triangle, the sine of an angle (A) is defined as the ratio between the length of the side that is opposite that angle (a) (which is not the hypotenuse) to the length of the hypotenuse (h):

sin A = a / hCode language: SQL (Structured Query Language) (sql)
SQL_trigonometry_triangle

For the inverse of the SIN function, see the ASIN function.

Syntax

The following illustrates the syntax of the SIN function.

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

Argument

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

Return

The SIN function returns a floating-point number.

Examples

The following statement returns the sine values of  π,/2 and π/6.

SELECT SIN(PI()/2) sin_half_pi, 
       SIN(PI()/6) sin_one_sixth_pi;Code language: SQL (Structured Query Language) (sql)
 sin_half_pi | sin_one_sixth_pi
-------------+------------------
           1 |              0.5
(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 SIN function with the same behavior.

Was this tutorial helpful ?