SQL COT Function

The SQL Server COT Function is a Mathematical Function that calculates the trigonometry Cotangent for the specified expression. The syntax of the COT Function is

SELECT COT (Float_Expression)
FROM [Source]

SQL COT Function Example

The mathematical formula for this function is COT(x) = 1 / TAN(x). The COT Function calculates the Cotangent value for the given angle. The following query shows you multiple ways to use the COT function.

Please refer TAN Function article in SQL Server. For this Function demo, we use the Math Table data.

DECLARE @i float
SET @i = 208.45

SELECT COT(@i)AS [SQLCotangent]

-- Calculating directly
SELECT COT(0.24)AS [SQLCotangent]

-- Calculating directly
SELECT COT(10.232)AS [SQLCotangent]

-- Calculating directly
SELECT COT(1)AS [SQLCotangent]
SQL COT Example 1

We used the COT function to calculate the Cotangent value for the variable @i. It means COT(208.45) and was assigned the name ‘Cotangent’ using ALIAS.

SELECT COT(@i)AS [SQLCotangent]

SQL COT Function Example 2

We are going to calculate the Cotangent value for all the records present in [Tax Amount] and [Service Grade] using COT Mathematical Function.

SELECT [EnglishProductName]
      ,[SalesAmount]
      ,[TaxAmt]
      ,COT([TaxAmt]) AS [Tax Cotangent]
      ,[Service Grade] AS Grade
      ,COT ([Service Grade]) AS [COT Function] 
  FROM [Mathemetical Functions]
SQL COT FUNCTION 2
Categories SQL