The SQL DISTINCT command with the SQL POWER() function can be used to retrieve unique data depending on a specified expression.
SQL POWER() is a built-in function used to return the value of the specified expression to the specified power. SQL POWER function is used to return the value of the determined expression to the specified power. SQL POWER() method returns the value of a number raised to another, where both of the numbers are passed as arguments.
SELECT POWER (float_expression, y);
- Float_expression: This is the expression whose value is to be calculated raised to absolute power, and that expression can be implicitly converted to float.
- Y: The value of the power. It can be an expression of exact numeric datatype except for bit datatype. If the value of power is negative, then 0 will be returned.
Select Power (2, 3);
Here, 2 is the expression, and 3 is the power.
Select Power (-2 ,3);
Here, the value of the negative expression is calculated where -2 is the expression and 3 is the power.
Select Power (2, -3);
Here, the value of power was negative. So, 0 was returned.
Select Power (-2, -3);
Here, 0 is returned as the value of power is negative. It does not matter whether the float expression is negative or not.
Select Power (2, 0);
Here, the power value is 0, and any expression whose power is 0 returns value 1.
Select Power (2, 1);
Here, the value of power is 1. So, any value whose power is raised to 1 returns the same value.
Select Power (5*2, 2);
Here, the value of the arithmetic expression can also be calculated. So, (5*2) expression, which results in 10 when raised to power 2, gave the appropriate result.