The SQL SQRT function is used to determine the square root of any number. You can use the SELECT statement to determine the square root of any number as follows:
SQL> select SQRT(16); +----------+ | SQRT(16) | +----------+ | 4.000000 | +----------+
You see the float value here because internally SQL will manipulate the square root of the float data type.
You can use the SQRT function to find out the square root of different records. To better understand the SQRT function, consider the table Table_employee, which has the following entries:
SQL> SELECT * FROM Table_employee; +------+------+------------+--------------------+ | id | name | work_date | daily_typing_pages | +------+------+------------+--------------------+ | 1 | Ravi | 2007-01-24 | 250 | | 2 | Greg | 2007-05-27 | 220 | | 3 | Neha | 2007-05-06 | 170 | | 3 | Neha | 2007-04-06 | 100 | | 4 | Raj | 2007-04-06 | 220 | | 5 | Indi | 2007-06-06 | 300 | | 5 | Indi | 2007-02-06 | 350 | +------+------+------------+--------------------+
Now suppose that based on the table above you want to calculate the square root of all dialy_typing_pages, then you can do this using the following command:
SQL> SELECT name, SQRT(daily_typing_pages) -> FROM Table_employee; +------+--------------------------+ | name | SQRT(daily_typing_pages) | +------+--------------------------+ | Ravi | 15.811388 | | Greg | 14.832397 | | Neha | 13.038405 | | Neha | 10.000000 | | Raj | 14.832397 | | Indi | 17.320508 | | Indi | 18.708287 | +------+--------------------------+
An example of the POWER function in SQL:
SQL> select POWER(2,3); +------------+ | POWER(2,3) | +------------+ | 8.000000 | +------------+ SQL> select POWER(5,4); +------------+ | POWER(5,4) | +------------+ | 625.0000 | +------------+
Mike clark
source share