Contents¶
math¶
Some basic math in SQL
Module Contents
Functions¶
math.erf¶
Gauss error function
This function is a wrapper for the Python 3 implementation.
- Parameters
xfloat
- Language
- plpython3u
- Returns
- float
import math
return math.erf(x)
math.factorial¶
Factorial function using the
WITH RECURSIVE SQL feature.
Logical definition:
f(0) = 1
f(n) = n * f (n - 1)
- Parameters
p_nint
- Returns
- int
RETURN (
WITH RECURSIVE t AS (
SELECT 1 AS f, 0 AS n
UNION ALL
SELECT f * (n + 1), n + 1 FROM t
)
SELECT f FROM t WHERE n=p_n LIMIT 1
);