SQLite 3 reference · Math Functions
SQLite SQRT() Function
Return the square root of a number, such as sqrt(16) = 4. Negative numbers give NULL rather than an error.
SQLite 3 Since 3.35.0
Syntax
sqrt(X)
Parameters
| Parameter | Description |
|---|---|
X |
A number (text that looks like a number is converted). |
Return value
A floating-point number, or NULL.
Examples
SELECT sqrt(16) AS a, sqrt(2) AS b, sqrt(-1) AS c;
Output
a | b | c 4 | 1.4142135623730951 | NULL
Run this on your computer — see “Get Started” for setup.
SELECT round(sqrt(power(3, 2) + power(4, 2)), 2) AS distance;
Output
distance 5
Run this on your computer — see “Get Started” for setup.
This is one of SQLite's built-in math functions, available since 3.35.0 when SQLite is compiled with
SQLITE_ENABLE_MATH_FUNCTIONS (the default for the sqlite3 command-line tool and most language bindings). The
in-browser SQLite on this site is built without them, so the examples show output from standard SQLite instead.
Version history
| Version | Change |
|---|---|
| SQLite 3.35.0 | Added |
In other languages
SQRT()· PostgreSQL
Related
POWER()· Raise a number to a power, so power(2, 10) is 1024. pow() is another name for the same function.- SQL Aggregate Functions · tutorial