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

Home
Oracle PL/SQL Tutorial
1.Introduction
2.Query Select
3.Set
4.Insert Update Delete
5.Sequences
6.Table
7.Table Joins
8.View
9.Index
10.SQL Data Types
11.Character String Functions
12.Aggregate Functions
13.Date Timestamp Functions
14.Numerical Math Functions
15.Conversion Functions
16.Analytical Functions
17.Miscellaneous Functions
18.Regular Expressions Functions
19.Statistical Functions
20.Linear Regression Functions
21.PL SQL Data Types
22.PL SQL Statements
23.PL SQL Operators
24.PL SQL Programming
25.Cursor
26.Collections
27.Function Procedure Packages
28.Trigger
29.SQL PLUS Session Environment
30.System Tables Data Dictionary
31.System Packages
32.Object Oriented
33.XML
34.Large Objects
35.Transaction
36.User Privilege
Oracle PL/SQL Tutorial » Numerical Math Functions » POWER 
14.16.2.Using the POWER function

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  /

row created.

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

row created.

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

row created.

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

row created.

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

row created.

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

row created.

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

row created.

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

row created.

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

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

rows selected.

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

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

rows selected.

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

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

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)
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.