Using the POWER function : POWER « Numerical Math Functions « Oracle PL/SQL Tutorial






The POWER function requires two arguments.

The first argument is the value that you would like raised to some exponential power.

The second argument is the power (exponent) that you would like the number raised to.

SQL>
SQL>
SQL> -- create demo table
SQL> create table myTable(
  2    id           NUMBER(2),
  3    value        NUMBER(6,2)
  4  )
  5  /

Table created.

SQL>
SQL> -- prepare data
SQL> insert into myTable(ID,  value)values (1,9)
  2  /

1 row created.

SQL> insert into myTable(ID,  value)values (2,2.11)
  2  /

1 row created.

SQL> insert into myTable(ID,  value)values (3,3.44)
  2  /

1 row created.

SQL> insert into myTable(ID,  value)values (4,-4.21)
  2  /

1 row created.

SQL> insert into myTable(ID,  value)values (5,10)
  2  /

1 row created.

SQL> insert into myTable(ID,  value)values (6,3)
  2  /

1 row created.

SQL> insert into myTable(ID,  value)values (7,-5.88)
  2  /

1 row created.

SQL> insert into myTable(ID,  value)values (8,123.45)
  2  /

1 row created.

SQL> insert into myTable(ID,  value)values (9,98.23)
  2  /

1 row created.

SQL>
SQL> select * from myTable
  2  /

        ID      VALUE
---------- ----------
         1          9
         2       2.11
         3       3.44
         4      -4.21
         5         10
         6          3
         7      -5.88
         8     123.45
         9      98.23

9 rows selected.

SQL>
SQL> select power(value, 2) from myTable
  2  /

POWER(VALUE,2)
--------------
            81
        4.4521
       11.8336
       17.7241
           100
             9
       34.5744
    15239.9025
     9649.1329

9 rows selected.

SQL>
SQL> select power(value, 3) from myTable
  2  /

POWER(VALUE,3)
--------------
           729
      9.393931
     40.707584
    -74.618461
          1000
            27
    -203.29747
    1881365.96
    947834.325

9 rows selected.

SQL>
SQL>
SQL> -- clean the table
SQL> drop table myTable
  2  /

Table dropped.

SQL>








14.16.POWER
14.16.1.POWER(x, y) gets the result of x raised to the power y.
14.16.2.Using the POWER function
14.16.3.POWER(2, 1)
14.16.4.POWER(2, 3)
14.16.5.select power(2,3), power(-2,3)