Introduction SQL

Basic SQL

SQL Constraints

Advance SQL

SQL Joins

SQL Function


SQL POWER, SQRT Function


SQL POWER Function

SQL POWER function return n1 raised to a n2 power. n1 is base value and n2 is any numbers.

Supported Oracle SQL Version :

  • Oracle 8i
  • Oracle 9i
  • Oracle 10g
  • Oracle 11g
  • Oracle 12c

Syntax :

POWER(n1,n2)

Example :

Considering following example SQL POWER function.

SQL> SELECT POWER(4,2) "POWER" FROM DUAL;

     POWER
----------
        16

SQL> SELECT POWER(4,5) "POWER" FROM DUAL;

     POWER
----------
      1024

SQL> SELECT POWER(4,7) "POWER" FROM DUAL;

     POWER
----------
     16384


SQL SQRT Function

SQL SQRT function return the square root of the n number. SQRT function return the real number.

If n number is a NUMBER data type then n number can't negative number.
If n number is a BINARY_FLOAT and BINARY_DOUBLE data type and if:

  • n > 0 return positive value
  • n = 0 return 0 value
  • n = -0 return -0 value
  • n < 0 return NaN

Supported Oracle SQL Version :

  • Oracle 8i
  • Oracle 9i
  • Oracle 10g
  • Oracle 11g
  • Oracle 12c

Syntax :

SQRT(n)

Example :

Consider following example take n number, return the square root of the number.

SQL> SELECT SQRT(10) "SQRT" FROM DUAL;

      SQRT
----------
3.16227766

SQL> SELECT SQRT(16) "SQRT" FROM DUAL;

      SQRT
----------
         4

SQL> SELECT SQRT(25) "SQRT" FROM DUAL;

      SQRT
----------
         5