website logo
⌘K
🏠Homepage
👋Introduction
Key Concepts & Architecture
🚀Getting Started
👨‍💻SQL Reference
SQL Queries
SQL Clauses
SQL Data Types
SQL Functions
Schema
🚨Error Handling
🆚Differences Between Oxla vs. PostgreSQL
Docs powered by archbee 

SIN

14min

This article will guide you on how to use the SIN() function, with its syntax and examples.

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.

Syntax
|
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
|
SELECT SIN(5);


It will return the sine value of 5.

Output
|
+-----------------------+
| 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
|
SELECT SIN(-3);


The output will be as follows.

Output
|
+----------------------+
| 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
|
SELECT SIN(5.8732);


The output will be as follows.

Output
|
+----------------------+
| 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
|
SELECT sin(8.5 * 2.3);


You will get the following output:

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 query 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 a table
|
CREATE TABLE sineTable(initialValue int);
INSERT INTO sineTable(initialValue)
VALUES (-5),(18), (0),(-27);


2) Run the query below to get the output of a sine value:

Select sin
|
SELECT * ,SIN(initialValue) AS sinValue FROM sineTable;


3) The final result will have the initialValue column with the source value and the sinValue column with their calculated sine values.  

Output
|
+---------------+-------------------------------+
| initialvalue  | sinValue                      |
+---------------+-------------------------------+
| -75           | 0.38778163540943045           |
| 180           | -0.8011526357338304           |
| 0             | 0                             | 
| -270          | 0.1760459464712114            |
+---------------+-------------------------------+




Updated 11 May 2023
Did this page help you?
Yes
No
PREVIOUS
LN
NEXT
Aggregation Functions
Docs powered by archbee 
TABLE OF CONTENTS
Overview
Syntax
Examples
Case #1: Sine a Positive Value
Case #2: Sine a Negative Value
Case #3: Sine a Fraction Value
Case #4: Sine With an Expression
Case #5: Using the SIN() Function With a Table

Dedicated to data analytics that provides 10x faster execution of analytical queries than current state of the art solutions. We are launching SOON! Join the waiting list for more info.




©2022 Oxla