In SQLite, we can use the TIME()
function to add a given number of seconds to a time value.
If we’re dealing with datetime values, we can use the DATETIME()
function.
In SQLite, we can use the TIME()
function to add a given number of seconds to a time value.
If we’re dealing with datetime values, we can use the DATETIME()
function.
Below are two options for removing duplicate rows from a table in PostgreSQL when those rows have a primary key or unique identifier column. The primary key is used in the query, but it’s ignored when comparing duplicates (due to the fact that primary keys prevent duplicate rows by definition).
The following examples delete duplicate rows but keep one. So in the case of say, three identical rows, it deletes two and keeps one.
Continue readingIn PostgreSQL, we can use the -
operator to subtract one or more hours from a time value.
By “time” value, this could be an actual time
value, a timestamp
, or an interval
. We can also subtract hours from a date
value or a date
and time
combination.
Below are two Oracle Database functions that convert uppercase characters to their lowercase equivalent.
Continue readingHere are four options for returning rows that contain lowercase characters in PostgreSQL.
Continue readingBelow are examples of using some of the more popular RDBMSs to return the Unix timestamp.
The Unix timestamp (also known as Unix Epoch time, Unix time, or POSIX time) is the number of seconds that have elapsed since 00:00:00 Thursday, 1 January 1970, Coordinated Universal Time (UTC).
Continue readingHere are two options for returning the number of days in a given month in SQLite. This could be the number of days in the current month, or it could be based on a given date.
Continue readingIf you ever encounter a character column that should be numeric, there’s always a possibility that it contains non-numeric data that you don’t know about.
For example, someone might have set up a Price
column as a varchar
column that should have been a numeric
column, and now you need to clean up after them. You might start by identifying all non-numeric data so that you can work out what to do with it before converting the column to a numeric type.
In SQL, you can run a query to return non-numeric data from the column. The query you use will largely depend on your DBMS.
Continue readingIf you have a column in a database table that contains character data, but some rows also contain numbers, you can use the following SQL queries to return just those rows that don’t contain numbers within the value.
Continue readingHere are some options for deleting duplicate rows from a table in Oracle Database when those rows have a primary key or unique identifier column.
In such cases, the primary key must be ignored when comparing duplicate rows (due to the fact that primary keys hold unique values).
Continue reading