MySQL COT Function

MySQL COT function is one of the Numeric Functions which calculates the trigonometry cotangent of the specified expression. The mathematical formula for this is: COT(x) = 1 / TAN(x). The basic syntax of the COT is as shown below:

SELECT COT (Numeric_Expression)
FROM Source

To demonstrate this Numeric method, we are going to use the below shown data

Numeric Table 1

MySQL COT Function Example

The COT returns the trigonometric cotangent value of any numeric value, and the following query shows multiple ways to use this function.

-- Cotangent of Negative Value
SELECT COT(-120.75) AS `Cotangent Value`;

-- Cotangent of Positive Value
SELECT COT(127.96) AS `Cotangent Value`;

-- Cotangent of Numeric Expression
SELECT COT(1.75 + 2.25 - 4.00) AS `Cotangent Value`;

-- Cotangent of string value
SELECT COT('0.74') AS `Cotangent Value`;

-- Cotangent of String
SELECT COT('MySQL') AS `Cotangent Value`;

-- Cotangent of NULL Value
SELECT COT(NULL) AS `Cotangent Value`;

From the screenshot below, you can see that we used the COT function to find the Cotangent values of different values. Here, we assigned a new name to the MySQL result as ‘Cotangent Value’ using the ALIAS Column.

Example 2

This Numeric method also allows you to find the cotangent values for the data in a table column. In this example, we are going to find the cotangent for all the records present in the Tax Amount column and Service Grade column.

--  Cotangent Example

SELECT Product, Color,
		StandardCost, Sales, TaxAmt,
        COT(TaxAmt) AS `Tax Cotangent Value`,
        ServiceGrade,
        COT(ServiceGrade) AS `Grade Cotangent Value`
FROM `numeric functions`;
MySQL COT Function Example 3