SQL ATAN Function

The SQL Server ATAN function is a Mathematical Function that calculates the trigonometry Arc tangent for the specified expression. The SQL Arc tangent is also called the inverse of a TANGENT Function. The syntax of the ATAN Function is

SELECT ATAN (Float_Expression)
FROM [Source]

For this demo, we use the below shown Math Table data

SQL Mathematical Functions

SQL ATAN Function Example

It calculates the Arctangent value for the given angle. The following query shows multiple ways to use the ATAN function.

In the following SELECT statement, we used the ATAN mathematical function to calculate the Arc TANGENT value for the variable @i. It means ATAN(-208.80) and is assigned a new name, ‘Arc Tangent’, using the ALIAS column name.

DECLARE @i Float
SET @i = -208.80

SELECT ATAN(@i) AS [Arc Tangent]

-- Calculating ATAN directly
SELECT ATAN(0.27) AS [Arc Tangent]

-- Calculating ATAN directly
SELECT ATAN(22.25 + 78.55 - 140.77) AS [Arc Tangent]
ATAN Function or Arc Tangent Example 1

ATAN Function Example 2

In the following query, we will calculate the Arctangent value for all records present in [Service Grade] using the SQL Server Function. Please refer to the ASIN and ACOS functions from the SQL Mathematical Functions to find the arc sine and arc cosine values. Also, check the ATN2.

SELECT [EnglishProductName]
      ,[Color]
      ,[StandardCost]
      ,[SalesAmount]
      ,[Service Grade] AS Grade
      ,ATAN([Service Grade]) AS [Arc Tangent] 
  FROM [Mathemetical Functions]
ATAN FUNCTION 2
Categories SQL

Comments are closed.