The ACOS()
function in SQLite is used to calculate the arc cosine (inverse cosine) of a given numeric value. The result is the angle in radians whose cosine is the specified number.
Tag: functions
A Comparison of 6 SQL Rank Functions
SQL rank functions can be handy things to have when analysing data. Most major RDBMSs implement a similar bunch of ranking functions, usually with the same names. These rank functions allow us to assign rankings to rows based on specific criteria.
In this article, we’ll look at six commonly used SQL ranking functions, and observe how they differ. We’ll throw them all together into a single query and see their results side by side.
The rank functions in question are: ROW_NUMBER()
, RANK()
, DENSE_RANK()
, NTILE()
, PERCENT_RANK()
, and CUME_DIST()
.
4 Functions that Trim a String in PostgreSQL
PostgreSQL provides us with various string functions, including some that allow us to trim a given string on both sides or a given side.
Below are four functions that we can use to trim strings in PostgreSQL.
Continue readingUnderstanding the Difference Between SCALE(), MIN_SCALE() and TRIM_SCALE() in PostgreSQL
Anyone who looks at PostgreSQL’s list of mathematical functions will notice that there are some functions that have “scale” in their name. In particular, scale()
, min_scale()
, and trim_scale()
.
While these functions all have a similar name, they each have a different purpose. That said, they’re all related to the scale of the given number. The scale is the number of digits to the right of the decimal point in a number. For example, the number 1.95 has a scale of 2, and 1.958 has a scale of 3.
Continue readingList of Array Functions in PostgreSQL
Below is an alphabetical list of functions that we can use when working with arrays in PostgreSQL.
Continue readingA Quick Look at the FACTORIAL() Function in PostgreSQL
In PostgreSQL, factorial()
is a mathematical function that returns the factorial of a given integer. We pass the integer (it accepts bigint
), and it returns the factorial as a numeric value.
In mathematics, the factorial is the product of all positive integers less than or equal to a given positive integer. It’s denoted by that integer and an exclamation point.
Continue readingA Quick Look at the MD5() Function in PostgreSQL
In PostgreSQL, the md5()
function computes the MD5 hash of the specific text, and outputs the result in hexadecimal.
We pass the text as an argument when calling the function.
Continue reading2 Functions that Return the Position of a Substring within a String in PostgreSQL
PostgreSQL sometimes provides us with multiple functions that basically do the same thing. Such is the case with the following two functions that return the position of a given substring within a string.
Continue readingA Quick Look at TO_HEX() in PostgreSQL
In PostgreSQL, we can use the to_hex()
function to convert a number to its equivalent hexadecimal representation.
The function accepts the number as an integer or bigint, and it returns the result as a text representation of its hexadecimal equivalent.
Continue readingA Quick Look at the ASCII() Function in PostgreSQL
In PostgreSQL, we can use the ascii()
function to get the numeric code of the first character of the argument.
When using UTF8, the function returns the Unicode code point of the character. Other multibyte encodings require an ASCII character.
Continue reading