The SIN function in Oracle SQL is a trigonometric function that calculates the sine of a given angle.
The most important thing to remember is that the SIN function, like all trigonometric functions in Oracle, requires the angle to be specified in radians, not degrees.
What is the SIN Function in Oracle?
The SIN(n) function takes a number n, which represents an angle in radians, and returns its sine as a value between -1 and 1.
If your angle is in degrees, you must convert it to radians before passing it to the SIN function. The formula for conversion is: radians = degrees * (PI / 180).
SIN Function Syntax
The syntax for SIN is very simple:
SIN(n)
Let's break that down:
n(the number): The angle you want to find the sine of, expressed in radians.
Oracle SIN Function Examples
Here are two practical examples of how to use SIN.
Example 1: Finding the Sine of 30 Degrees
This example shows how to find the sine of 30 degrees. To do this, we must first convert 30 degrees to radians using the formula 30 * (PI / 180). We will use 3.14159265359 as an approximation for PI.
Query:
SELECT
SIN(30 * 3.14159265359 / 180) AS "Sine_of_30_Degrees"
FROM DUAL;
Result:
Sine_of_30_Degrees
------------------
.5
Example 2: Finding the Sine of 90 Degrees (PI/2 Radians)
The sine of 90 degrees (or $\pi/2$ radians) is 1. This example shows the calculation using the radian value directly.
Query:
SELECT
SIN(3.14159265359 / 2) AS "Sine_of_90_Degrees"
FROM DUAL;
Result:
Sine_of_90_Degrees
------------------
1
