In PostgreSQL, the SUM()
function computes the sum of the non-null input values and returns the result.
In other words, it adds numbers and returns the result.
Continue readingIn PostgreSQL, the SUM()
function computes the sum of the non-null input values and returns the result.
In other words, it adds numbers and returns the result.
Continue readingWith Oracle Database, we can use the TO_CHAR(datetime)
function to return the century from a datetime value.
To do this, we can use either the CC
format element, or the SCC
format element. We can combine these with other format elements to do things like, display the ordinal number, spell out the century, etc.
If you need to find the character sets that are available in your MariaDB installation, check out the following two methods.
Continue readingIn Oracle Database, there are a number of views that we can query to find out whether a table exists.
Continue readingIn PostgreSQL, the AVG()
function computes the average (arithmetic mean) of all the non-null input values, and returns the result.
In MySQL, you can run a query like the following to return non-numeric data from the column.
This can be helpful if you ever find a column that contains numeric data, but it was set up as a varchar
or char
column. You can use this query to find any non-numeric values that might have been inserted into the column. You can then deal with it any way you like, such as convert them to numeric, then change the column type.
Some DBMSs such as Oracle, MySQL, and MariaDB have a DESCRIBE
command that returns information about tables and views. It goes DESCRIBE table
where table is the name of the table or view, and it can also be followed by a column name if you only want information about a specific column.
PostgreSQL doesn’t have a DESCRIBE TABLE
command as such, but there are alternatives.
MariaDB includes two built-in functions that allow us to get the ASCII code from a given character.
Continue readingIn SQLite, we can use the IF EXISTS
clause of the DROP TABLE
statement to check whether the table exists or not before dropping it.
There may be occasions where you need to check a column for non-numeric values. For example, you discover that a column is a varchar
column when it really should be a numeric column.
This is easily done in SQL Server with the ISNUMERIC()
function.