We’ll show why and how to get what we call “groups of groups”, or aggregations of aggregated data. It means using nested
GROUP BY queries.
LIKE operator is generally well-known. Most SQL users know how to find columns that contain a string, start with a string, or end with a string. But some of them, especially beginners, may not find obvious some other interesting uses of
We saw in another article how to build an array from an SQL query (from each row, or from a column). This article shows how to loop over an array items.
Different databases support different ways to get the first and last day of the month. Let’s see how to do it in MariaDB and MySQL.
Db2 ordinary arrays can be constructed and populated from an SQL query. Let’s see how to do it.
Finding users who never logins is not trivial in SQL Server. But we can do it by creating a logon trigger.
Sometimes we need to extract a text from the database to show it in a web page. The text should be showed as is, including any HTML tags and special characters. Normally the encoding is done by a web application, but there are cases when an SQL string is expected to return HTML encoded texts.
It is well-known how to get the highest and lowest values in a table column, but it is a bit less known how to get the highest and lowest values in a row. Let’s see how to do it.
In statistics, the mode is the function that returns the element that appear most often in a series. This is what people try to achieve when they run MAX(COUNT(*))… and they find out that it doesn’t work. Let’s see how to obtain the mode in SQL.
Sometimes you want to count all occurrences of a substring into a bigger string. For example, you may want to count all occurrences of a name in a text. This can be done, but it’s not straight-forward because SQL Server doesn’t have a specific function to do it.