In MariaDB, the AVG()
function returns the average value of the given expression.
The DISTINCT
option can be used to return the average of the distinct values (i.e. remove duplicates before calculating the average).
NULL
values are ignored.
In MariaDB, the AVG()
function returns the average value of the given expression.
The DISTINCT
option can be used to return the average of the distinct values (i.e. remove duplicates before calculating the average).
NULL
values are ignored.
In MariaDB, 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 an expression.
Continue readingSQL Server has a HAS_DBACCESS()
function that returns information about whether the user has access to a specified database.
In MariaDB, MIN()
is an aggregate function that returns the minimum value in a given expression.
In MariaDB, MAX()
is an aggregate function that returns the maximum value in a given expression.
In SQL, LPAD()
is a commonly used function that pads the left part of a string with a specified character. The function can be used on strings and numbers, although depending on the DBMS, numbers may have to be passed as a string before they can be padded.
DBMSs that have an LPAD()
function include MySQL, MariaDB, PostgreSQL, and Oracle.
DBMSs that don’t have an LPAD()
function include SQL Server and SQLite (although there are other ways to apply left padding in these DBMSs).
In SQL, RPAD()
is used to pad the right part of a string with a specified character. The function can be used on strings and numbers, although depending on the DBMS, numbers may have to be passed as a string before they can be padded.
DBMSs that have an RPAD()
function include MySQL, MariaDB, PostgreSQL, and Oracle.
DBMSs that don’t have an RPAD()
function include SQL Server and SQLite.
Some RDBMSs have a GROUP_CONCAT()
function that allows you to return a query column as a delimited list (for example, a comma separated list). MySQL and MariaDB are two that have such a function.
PostgreSQL and SQL Server have similar functions called STRING_AGG()
.
Oracle, on the other hand, has the LISTAGG()
function that does pretty much the same thing (and perhaps more).
So you could say that LISTAGG()
is Oracle’s GROUP_CONCAT()
equivalent.
When using the TO_CHAR()
function to format a number in Oracle Database, you can use the V
format element to a return a value multiplied by 10n (and if necessary, round it up), where n
is the number of 9
s after the V
.
When formatting dates in Oracle Database, we have the option of using RR
and YY
to return a two digit year.
These two format elements are similar. The difference is in how they interpret two digits years.
We also have the option of using RRRR
and YYYY
when returning four digit years.