AppDividend
Latest Code Tutorials

SQL ACOS Function Example | acos() in SQL

0

SQL ACOS() is an inbuilt function that is used for finding the arc cosine of a number. The number should be in the range of -1 to 1; otherwise, it will return NULL.

SQL COS()

SQL ACOS() function returns the arccosine of a number. In other words, this function returns the angle, in radians, whose cosine is the specified float expression. The return data type is float.

Syntax

SELECT ACOS (Number);

Parameters

Number: The number whose arc cosine value is to be retrieved.

Examples

Query 1

SELECT COS (1);

Output

0

Explanation

Here, the arc cosine value is returned.

Query 2

SELECT ACOS (1.02);

Output

NULL

Explanation

Here, the number specified was not within the range of -1 to 1, so NULL is returned.

Query 3

SELECT COS (NULL);

Output

NULL

Explanation

Passing of NULL value as the argument will return a NULL value.

Query 4

SELECT ACOS (0.25);

Output

1.318116071652818

Explanation

Here, arc cosine value is returned, which is of fractional type.

Query 5

SELECT DEGREE (ACOS (0.5));

Output

60

Explanation

As the value returned by ACOS value is in radians so to get value in degree. Here, Degree function is used for retrieving the degree of arc cosine value of the number.

See also

SQL RADIANS()

SQL ROUND()

SQL SIN()

SQL SQRT()

SQL SIGN()

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.