The SQL COT Function is one of the Mathematical Function which is used to calculate the trigonometry Cotangent for the specified expression.
The mathematical formula for this function is: COT(x) = 1 / TAN(x)
TIP: Please refer SQL TAN Function article to understand the functionality of tangent function.
SQL COT Function Syntax
The basic syntax of the COT Function in SQL Server is as shown below:
SELECT COT (Float_Expression) FROM [Source]
In this article we will show you, How to write COT Function in SQL Server with an example. For this demonstration, We are going to use the below shown data
SQL COT Function Example 1
The COT Function is used to calculate the Cotangent value for the given angle. The following query will show you the multiple ways to use COT function.
DECLARE @i float SET @i = 208.45 SELECT COT(@i)AS [SQL Cotangent] -- Calculating COT directly SELECT COT(0.24)AS [SQL Cotangent] -- Calculating COT directly SELECT COT(10.232)AS [SQL Cotangent] -- Calculating COT directly SELECT COT(1)AS [SQL Cotangent]
Within this cot function example query, Below lines of code is used to declare float variable and assigning the value.
DECLARE @i float SET @i = 208.45
In the below statement, We used Sql Server COT function to calculate the Cotangent value for the variable @i (It means COT(208.45)). We also assigned new name to that result as ‘SQL Cotangent’ using ALIAS Column.
SELECT COT(@i)AS [SQL Cotangent]
In the next statements, We used the COT Function directly on the float values.
SQL COT Function Example 2
In this example, We are going to calculate the Cotangent value for all the records present in [Tax Amount] and [Service Grade] using COT Function.
SELECT [EnglishProductName] ,[SalesAmount] ,[TaxAmt] ,COT([TaxAmt]) AS [Tax Cotangent] ,[Service Grade] AS Grade ,COT ([Service Grade]) AS [COT Function] FROM [Mathemetical Functions]
Thank You for Visiting Our Blog