Javatpoint Logo
Javatpoint Logo

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_ID Product_Name Product_Quantity Purchasing_Price Selling_Price Release_Date Product_Rating
0.1 P1 0.250 0.5 NULL 2022-04-30 NULL
0.2 P4 0.500 0.45 -0.8 2022-01-28 0.25
0.3 P2 0.350 0.85 0.250 2022-02-18 0.15
0.4 P7 0.850 0.355 NULL 2021-12-25 0.45
0.5 P6 0.900 0.5 -0.500 2021-10-15 NULL
0.6 P8 0.750 0.110 -0.95 2022-01-28 -0.9
0.7 P10 0.250 0.550 0.258 2022-04-11 NULL

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_ID ASIN_Value_of_Product_ID
0.1 0.10016
0.2 0.2013579
0.3 0.30469
0.4 0.411516
0.5 0.523598
0.6 0.6435011
0.7 0.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_Price ASIN_Value_of_PurchasingPrice Selling_Price ASIN_Value_of_SellingPrice
0.5 0.523598 NULL -
0.45 0.46676 -0.8 -0.9272952
0.85 1.01598 0.250 0.25268
0.355 0.362914 NULL -
0.5 0.523598 -0.500 0.523598
0.110 0.11022 -0.95 -1.25323
0.550 0.582364 0.258 0.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_Rating ASIN_Value_of_productrating
NULL -
0.25 0.25268
0.15 0.150568
0.45 0.46676533
NULL -
-0.9 -1.1197695
NULL -






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA