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 COT function is: COT(x) = 1 / TAN(x). The basic syntax of the COT in MySQL is as shown below:

SELECT COT (Numeric_Expression)
FROM Source

To demonstrate this MySQL COT Numeric function, we are going to use the below shown data

MySQL COT Function 1

MySQL COT Function Example 1

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

-- MySQL COT Function Example

-- 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.

MySQL COT Function Example 2

MySQL COT Example 2

The MySQL COT Numeric 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.

-- MySQL Cotangent Example
USE mysqltutorial;
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