In PostgreSQL, the trunc()
function truncates a number.
More specifically, it truncates the number either toward zero, or to a specific number of decimal places.
Continue readingIn PostgreSQL, the trunc()
function truncates a number.
More specifically, it truncates the number either toward zero, or to a specific number of decimal places.
Continue readingIn PostgreSQL, the ceiling()
function is used for rounding a number up to the nearest integer.
It’s similar to round()
, except that it only rounds up. The round()
function will round up or down as required.
It’s also similar to floor()
, except that floor()
rounds down instead of up.
In PostgreSQL, the floor()
function is used for rounding a number down to the nearest integer.
It’s basically the opposite of ceiling()
, which rounds a number up.
It’s also similar to round()
, except that it only rounds down. The round()
function will round up or down as required.
In PostgreSQL, the round()
function is used for rounding a number.
The function can work in one of two ways, depending on how you use it. You can make it round the number to the nearest integer, or to a specified number of decimal places.
This is determined by the number of arguments you pass to the function when you call it.
Continue readingIn Postgres, the age()
function returns the age based on two timestamp or date variables.
The result is returned using years and months, rather than just days.
For example, a result might look like this: 3 years 2 mons 30 days.
Continue readingIn SQLite, iif()
is a conditional function that returns the second or third argument based on the evaluation of the first argument.
It’s logically equivalent to CASE WHEN X THEN Y ELSE Z END
.
iif()
is an abbreviation for Immediate IF.
The iif()
function was introduced in SQLite 3.32.0, which was released on 22 May 2020.
In SQLite, the char()
function returns a string based on the unicode code points provided as arguments.
You can provide one or more arguments, each of which is a unicode code point. The function then returns a string based on those code points.
Continue readingSQLite has a function called last_insert_rowid()
that returns the ROWID of the last row insert from the database connection which invoked the function.
The SQLite length()
function returns the number of characters in a string, number, or blob.
If there are any NUL characters, it returns the number of characters before the first NUL character.
Continue readingThe SQLite quote()
function allows you to escape a string so that it’s suitable for inclusion in an SQL statement.
Strings are surrounded by single-quotes with escapes on interior quotes.
BLOBs are encoded as hexadecimal literals.
Note that strings with embedded NUL characters cannot be represented as string literals in SQL. If you include strings with embedded NUL characters, the returned string literal is truncated prior to the first NUL.
Continue reading