PostgreSQL SIN() Function
The PostgreSQL SIN() function returns trigonometric sine of an angle (angle should be in radians). The other variant of this function is SIND() which returns trigonometric sine of an angle (angle should be in degrees).
Syntax
/* specify angle in radians */ SIN(x) /* specify angle in degrees */ SIND(x)
Parameters
x |
Required. Specify the angle. |
Return Value
Returns the trigonometric sine of an angle.
Example 1:
The example below shows the usage of SIN() function.
SELECT SIN(0); Result: 0 SELECT SIN(1); Result: 0.8414709848078965 SELECT SIN(-1); Result: -0.8414709848078965 SELECT SIN(2); Result: 0.9092974268256817 SELECT SIN(-2); Result: -0.9092974268256817 SELECT SIN(PI()); Result: 1.2246467991473532e-16 SELECT SIND(30); Result: 0.5 SELECT SIND(45); Result: 0.7071067811865475 SELECT SIND(90); Result: 1
Example 2:
Consider a database table called Sample with the following records:
Data | x |
---|---|
Data 1 | -10 |
Data 2 | -5 |
Data 3 | 0 |
Data 4 | 5 |
Data 5 | 10 |
The statement given below can be used to calculate the trigonometric sine value of column x.
SELECT *, SIN(x) AS SIN_Value FROM Sample;
This will produce the result as shown below:
Data | x | SIN_Value |
---|---|---|
Data 1 | -10 | 0.5440211108893698 |
Data 2 | -5 | 0.9589242746631385 |
Data 3 | 0 | 0 |
Data 4 | 5 | -0.9589242746631385 |
Data 5 | 10 | -0.5440211108893698 |
❮ PostgreSQL Functions