In PostgreSQL, lcm()
is a mathematical function that returns the least common multiple. We pass two numbers and the function returns the smallest strictly positive number that is an integral multiple of both inputs.
Tag: mathematical functions
Understanding PostgreSQL’s LOG10() Function
In PostgreSQL, log10()
is a mathematical function that returns the base 10 logarithm of its argument.
It was added in PostgreSQL 12 as a SQL-standard equivalent of the existing log()
function.
There is a difference between the two functions though, because log()
allows us to specify which base to use (although it defaults to base 10), whereas log10()
uses base 10 only.
Using TRIM_SCALE() in PostgreSQL
In PostgreSQL, we can use the trim_scale()
function to remove any trailing zeros from the end of the fractional part.
This doesn’t change the value, it merely reduces the number characters whenever there are unnecessary zeros on the end.
Continue readingHow MIN_SCALE() Works in PostgreSQL
In PostgreSQL, min_scale()
is a mathematical function that returns the minimum scale needed to represent the supplied value precisely.
The “scale” is the number of fractional decimal digits. For example, a value of 1.9500 has a minimum scale of 2, whereas 1.957 has a minimum scale of 3.
We pass the value to the function as a numeric
argument, and it returns the result as an integer.
SUM() Function in SQL Server
In SQL Server, the SUM()
aggregate function returns the sum of a given expression.
It can also be used to return the sum of all distinct (unique) values in the expression.
SUM()
only works on numeric columns. Null values are ignored.
PostgreSQL Math Functions
Below is a full list of mathematical functions available in PostgreSQL.
These are arranged into the following four categories:
- Mathematical Functions
- Random Functions
- Trigonometric Functions
- Hyperbolic Functions
How Atanh() Works in PostgreSQL
In PostgreSQL, atanh()
is a hyperbolic function that returns the inverse hyperbolic tangent of its argument.
The argument and return value are provided as a double precision value.
Continue readingHow Acosh() Works in PostgreSQL
In PostgreSQL, acosh()
is a hyperbolic function that returns the inverse hyperbolic cosine of its argument.
The argument and return value are provided as a double precision value.
Continue readingHow Asinh() Works in PostgreSQL
In PostgreSQL, asinh()
is a hyperbolic function that returns the inverse hyperbolic sine of its argument.
The argument and return value are provided as a double precision value.
Continue readingHow Cosh() Works in PostgreSQL
In PostgreSQL, cosh()
is a hyperbolic function that returns the hyperbolic cosine of its argument.
The argument and return value are provided as a double precision value.
Continue reading