SQL - SQRT Function



SQL Tutorial - SQL SQRT Function


The SQRT function is used to get the square root of any number.

SQL SQRT() SYNTAX


Select SQRT();

The SQRT Function Example


Select SQRT(16) as SquareRoot;

Here the input parameter is 16.

SquareRoot
4

Consider the Products table which has the following records:

ProductID ProductName ProductPrice
Prd001 Pen 40.25
Prd002 Pen 100.75
Prd003 Eraser 10.35
Prd004 Pencil 20.45
Prd005 Book 50.65
Prd006 Gum 25.22

To calculate the square root of all the prices of the products, use the Sqrt function on the ProductPrice column as shown below.

SELECT ProductName, SQRT(ProductPrice) SqrtPrice FROM Products;

ProductName SqrtPrice
Pen 6.34428877022476
Pen 10.0374299499424
Eraser 3.21714158842908
Pencil 4.52216762183801
Book 7.11688133946323
Gum 5.02195181179589