POW Function in SQL
The POW is a mathematical function in SQL which returns the value of a number raised to the power of another number. This function is similar to the POWER function. In the POW function, we have to pass the two number as the argument in which one number acts as exponent and other acts as the base.
Syntax of POW String Function
In this POW function, following are the two arguments:
1. Number1: It acts as the base in the power function
2. Number2: And, it acts as the exponent.
In Structured Query Language, we can also use the POW function with the integer columns of the table as shown in the following block:
In this syntax, we used the POW function with existing table of SQL. Here, we have to define the name and columns of that table on which we want to perform the POW function.
Examples of POW String function
Example 1: The following POW function returns the value of base value 5 and exponent value 3:
Example 2: The following POW function returns the 625 in result:
Example 3: This example uses the mathematical POW function with the SQL table: In this third example, we will create the new table through which we will perform the POW function with the integer 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:
Query 1: The following SELECT query uses the POWER function with the Product_Quantity and Power_ID columns of the above Product_Details table:
This query shows the greatest value from the product id and quantity of each product.
Query 2: The following SELECT query uses the POWER function with the Purchasing_Price and Selling_Price columns of those products whose Product_ID is greater than 103 in the above Product_Details table:
Query 3: The following SELECT query uses the POWER function with the Product_Rating column of the above Product_Details table: