Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Python Programs
    • Java Programs
    • SQL FAQ’s

MySQL COS Function

by suresh

MySQL COS function is one of the Numeric Functions, which calculates the trigonometry cosine of the specified expression. The mathematical formula for this Cosine function is COS(x) = Length of the Adjacent Side / Length of the Hypotenuse.

The basic syntax of the COS in MySQL is as shown below:

SELECT COS (Numeric_Expression)
FROM Source

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

MySQL COS Function 1

MySQL COS Function Example 1

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

-- MySQL COS Function Example

-- Cosine of Negative Value
SELECT COS(-10.57) AS `Cosine Value`;

-- Cosine of Positive Value
SELECT COS(7.96) AS `Cosine Value`;

-- Cosine of Numeric Expression
SELECT COS(1.75 + 2.25 - 4.00) AS `Cosine Value`;

-- Cosine of string value
SELECT COS('3.14') AS `Cosine Value`;

-- Cosine of String
SELECT COS('MySQL') AS `Cosine Value`;

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

MySQL COS Function Example 2

MySQL COS Example 2

The MySQL COS Numeric Function also allows you to find the cosine values for the data in table columns. In this example, we are going to find the cosine for all the records present in the Tax Amount column, and Service Grade column.

-- MySQL Cosine Function Example
USE mysqltutorial;
SELECT Product, Color,
		StandardCost, Sales, TaxAmt,
        COS(TaxAmt) AS `Tax Cosine Value`,
        ServiceGrade,
        COS(ServiceGrade) AS `Grade Cosine Value`
FROM `numeric functions`;

OUTPUT
MySQL COS Function Example 3

Placed Under: MySQL

  • How to Download MySQL
  • Install MySQL on Windows
  • MySQL Create Database
  • MySQL Delete Database
  • MySQL Create Table
  • MySQL Drop Table
  • MySQL SELECT Statement
  • MySQL ALIAS Column
  • MySQL Distinct
  • MySQL Insert Statement
  • MySQL Delete
  • MySQL Truncate Table
  • MySQL WHERE Clause
  • MySQL Order By
  • MySQL Group By
  • MySQL Having Clause
  • MySQL LIMIT
  • MySQL Arithmetic Operators
  • MySQL COALESCE Function
  • MySQL AND Operator
  • MySQL NOT Operator
  • MySQL OR Operator
  • MySQL XOR Operator
  • MySQL BETWEEN Operator
  • MySQL Not Between Operator
  • MySQL GREATEST Function
  • MYSQL LEAST Function
  • MySQL LIKE Operator
  • MySQL NOT LIKE Operator
  • MySQL IFNULL Operator
  • MySQL NULLIF Operator
  • MySQL INTERVAL Operator
  • MySQL IS Operator
  • MySQL IN Operator
  • MySQL NOT IN Operator
  • MySQL IS NOT NULL
  • MySQL IS NULL
  • MySQL Inner Join
  • MySQL Cross Join
  • MySQL Right Join
  • MySQL Left Join
  • MySQL Aggregate Functions
  • MySQL Date Functions
  • MySQL Date Function
  • MySQL String Functions
  • MySQL Numeric Functions
  • C Tutorial
  • C# Tutorial
  • Java Tutorial
  • JavaScript Tutorial
  • Python Tutorial
  • MySQL Tutorial
  • SQL Server Tutorial
  • R Tutorial
  • Power BI Tutorial
  • Tableau Tutorial
  • SSIS Tutorial
  • SSRS Tutorial
  • Informatica Tutorial
  • Talend Tutorial
  • C Programs
  • C++ Programs
  • Java Programs
  • Python Programs
  • MDX Tutorial
  • SSAS Tutorial
  • QlikView Tutorial

Copyright © 2021 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy