ACOS Function in SQLThe ACOS() is a mathematics function which returns the arc cosine value of the given number in the Structured Query Language. We have to specify the number between -1 to 1, otherwise this function returns NULL value in output. Syntax of ACOS FunctionIn this SELECT syntax, we have to pass that numeric number in the function whose arc cosine value we want to find. In the Structured Query Language, we can also use the ACOS function in SELECT query with the table field: In this SELECT query, we have to define the name and field of that table on which we want to perform the ACOS function. Examples of ACOS functionExample 1: This example returns the arc cos value of the specified number: Output:
Example 2: This example returns the arc cos value of the specified number: Output:
Example 3: This example returns the arc cos value representation of 19: Output:
Example 4: This example uses the ACOS function with the SQL table. In this example, we will create the new table through which we will perform the ACOS function on the numeric fields of the table: The following shows the syntax to create the new table in SQL: The following CREATE statement creates the Product_Details table for storing the price and quantity of products: The following multiple INSERT queries insert the records of products with their selling and purchasing price into the Product_Details table:
Query 1: The following SELECT query uses the ACOS function with the Product_Quantity column of the above Product_Details table: This query shows the arc cos value of product id of each product. Output:
Query 2: The following SELECT query uses the ACOS function with the and Purchasing_Price and Selling_Price column of the above Product_Details table: This query shows the arc cosine value of purchasing price of each product. Output:
Query 3: The following SELECT query uses the ACOS function with the Product_Rating column of the above Product_Details table: This query shows the arc cosine value of rating of each product from the above table. Output:
Query 4: The following SELECT query uses the ACOS function with the Product_Quantity column of the above Product_Details table: This query shows the arc cosine value of quantity of each product from the above table. Output:
Query 5: The following SELECT query uses the ACOS function with the and Purchasing_Price and Selling_Price column of the above Product_Details table: This query shows the arc cosine value of purchasing and selling price of each product. Output:
Next TopicASIN Function in SQL
|