SQL ACOS Function

The SQL Server ACOS function calculates the trigonometry Arc cosine for the specified expression. The Arc cosine is also called the inverse of a COSINE Function, and the syntax of ACOS is

SELECT ACOS (Float_Expression)
FROM [Source]

TIP: The ACOS function only accepts float values between -1 and 1 and for this demo, we use the Math Table data.

SQL Mathematical Functions

SQL ACOS Function Example

The ACOS Function calculates the Arc cosine for the given angle. The following SQL Server query will show you multiple ways to use the Arc COSINE function.

DECLARE @i float
SET @i = -0.80

SELECT ACOS(@i) AS [Arc Cosine]

-- Calculating directly
SELECT ACOS(0.27) AS [Arc Cosine]

-- Calculating directly
SELECT ACOS(0.25 + 0.55 - 0.77) AS [Arc Cosine]
ACOS Arc COSINE Example 1

In the following SELECT statement, we used the ACOS function to calculate the Arccosine value for the variable @i. It means ACOS(-0.80) and is assigned a new name, ‘Arc Cosine’, using ALIAS COLUMN.

SELECT ACOS(@i) AS [Arc Cosine]

Example 2

We calculate the Arc cosine value for all the records present in [Service Grade] using the ACOS function. Please refer to the SQL ASIN and ATAN functions from the SQL Mathematical Functions to find the arc sine and arc tangent values.

SELECT [EnglishProductName]
      ,[Color]
      ,[StandardCost]
      ,[SalesAmount]
      ,[Service Grade]
      ,ACOS([Service Grade]) AS [Arc Cosine] 
  FROM [Mathemetical Functions]
ACOS Function Example 2
Categories SQL