ASIN Function in SQL

The ASIN is a SQL mathematics function which returns the arc sin of the specified number. This function returns NULL value, if the specified number is not between -1 to 1.

Syntax of ASIN Function

In the ASIN syntax, we have to pass that number whose arc sin value we want to calculate.

In the Structured Query Language, we can also use the ASIN function with the column of the table as shown in the following block:

In this syntax, we have to define the name and column of that table on which we want to perform the ASIN function.

Examples of ASIN function

Example 1: This example returns the ASIN value of the specified number:

Output:

ASIN_Value_of_0.5
0.523598

Example 2: This example returns the arc sin value of the specified number:

Output:

ASIN_Value_of_0.9
1.1197

Example 3: This example returns the ASIN value of 0.1:

Output:

ASIN_Value_of_0.1
0.10016

Example 4: This example uses the ASIN function with the SQL table.

In this example, we will create the new table through which we will perform the ASIN function on the columns 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:

The following SELECT statement displays the inserted records of the above Product_Details table:


Product_IDProduct_NameProduct_QuantityPurchasing_PriceSelling_PriceRelease_DateProduct_Rating
0.1P10.2500.5NULL2022-04-30NULL
0.2P40.5000.45-0.82022-01-280.25
0.3P20.3500.850.2502022-02-180.15
0.4P70.8500.355NULL2021-12-250.45
0.5P60.9000.5-0.5002021-10-15NULL
0.6P80.7500.110-0.952022-01-28-0.9
0.7P100.2500.5500.2582022-04-11NULL

Query 1: The following SELECT query uses the ASIN function with the Product_Quantity column of the above Product_Details table:

This query shows the arc sin value value of product id of each product.

Output:

Product_IDASIN_Value_of_Product_ID
0.10.10016
0.20.2013579
0.30.30469
0.40.411516
0.50.523598
0.60.6435011
0.70.775397

Query 2: The following SELECT query uses the ASIN function with the and Purchasing_Price and Selling_Price column of the above Product_Details table:

This query shows the arc sin value of purchasing and selling price of each product from the above table.

Output:

Purchasing_PriceASIN_Value_of_PurchasingPriceSelling_PriceASIN_Value_of_SellingPrice
0.50.523598NULL-
0.450.46676-0.8-0.9272952
0.851.015980.2500.25268
0.3550.362914NULL-
0.50.523598-0.5000.523598
0.1100.11022-0.95-1.25323
0.5500.5823640.2580.2609515

Query 3: The following SELECT query uses the ASIN function with the Product_Rating column of the above Product_Details table:

This query shows the arc sin value of rating of each product from the above table.

Output:

Product_RatingASIN_Value_of_productrating
NULL-
0.250.25268
0.150.150568
0.450.46676533
NULL-
-0.9-1.1197695
NULL-