SQL SIN()
Published Jun 18, 2023
The SIN() function in SQL is a mathematical function that returns the sine of an angle. It is compatible with various SQL database systems such as MySQL, PostgreSQL, Oracle, and SQL Server.
Syntax
SIN(angle)
Where angle is the angle in radians.
Example
In this example, we have a table called angles that contains the following angles in degrees:
| angle |
|---|
| 30 |
| 45 |
| 60 |
Below, the SIN() function is used to calculate the sine of each angle:
SELECT angle, SIN(angle) AS sine_valueFROM angles;
The output will be:
| angle | sine_value |
|---|---|
| 30 | 0.5 |
| 45 | 0.70710678 |
| 60 | 0.8660254 |
The SIN() function calculates the sine of each angle in degrees and returns the corresponding sine values.
Note: For the use of this method with SQL databases like MySQL, PostgreSQL, SQLite, or SQL Server, refer to their respective documentation for more details on the
SIN()function implementation and compatibility.
Learn SQL on Codecademy
- Learn to analyze data with SQL and prepare for technical interviews.
- Includes 9 Courses
- With Certificate
- Beginner Friendly.17 hours
- In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.
- Beginner Friendly.5 hours