Overview

SIN() is a numeric function that returns the trigonometric sine value of a specified angle in radians.

Syntax

The syntax of the SIN() function is as follows.

SIN (x)

The SIN() function requires one argument:

x:  A positive or a negative angle (or an expression that evaluates to an angle).

Examples

Case #1: Sine a Positive Value

The example below will use the SIN() function with a positive angle as the argument.

SELECT SIN(5);

It will return the sine value of 5.

+-----------------------+
| f                     |
+-----------------------+
| -0.9589242746631385   |
+-----------------------+

Case #2: Sine a Negative Value

The following example shows the SIN() function with a negative angle as the argument.

SELECT SIN(-3);

The output will be as follows.

+----------------------+
| f                    |
+----------------------+
| -0.1411200080598672  |
+----------------------+

Case #3: Sine a Fraction Value

The following example shows the SIN() function with a fractional value as the argument.

SELECT SIN(5.8732);

The output will be as follows.

+----------------------+
| f                    |
+----------------------+
| -0.3985959081271079  |
+----------------------+

Case #4: Sine With an Expression

The SIN() function can also include an expression, as shown in the example below:

SELECT sin(8.5 * 2.3);

You will get the following output:

+-----------------------+
| f                     |
+-----------------------+
| 0.6445566903363104    |
+-----------------------+

Case #5: Using the SIN() Function With a Table

In the following example, we will combine SIN() function with CREATE TABLE statement to obtain the sine values of a specific column.

  1. Create a new table named sineTable containing the initialValue column. Input some values with the negative and positive angles into the column.
CREATE TABLE sineTable(initialValue int);
INSERT INTO sineTable(initialValue)
VALUES (-5),(18), (0),(-27);
  1. Run the query below to get the output of a sine value:
SELECT * ,SIN(initialValue) AS sinValue FROM sineTable;
  1. The final result will have the initialValue column with the source value and the sinValue column with their calculated sine values.  
+---------------+-------------------------------+
| initialvalue  | sinValue                      |
+---------------+-------------------------------+
| -75           | 0.38778163540943045           |
| 180           | -0.8011526357338304           |
| 0             | 0                             | 
| -270          | 0.1760459464712114            |
+---------------+-------------------------------+