Database.Guide

Skip to content

Beginners

  • What is a Database?
  • Database Tutorial

SQL

  • SQL Tutorial
  • SQL Reference
  • SQL Joins Tutorial
  • SQL Transactions Tutorial
  • Basic SQL Queries

Categories

  • Azure SQL Edge (17)
  • Database Concepts (99)
  • Database Tools (72)
  • DBMS (9)
  • DuckDB (169)
  • MariaDB (424)
  • Microsoft Access (17)
  • MongoDB (265)
  • MySQL (602)
  • NoSQL (8)
  • Oracle (301)
  • PostgreSQL (480)
  • Redis (210)
  • SQL (697)
  • SQL Server (1,170)
  • SQLite (300)

Category: SQLite

How to Get the First Day of the Month in SQL

Posted on September 8, 2022 by Ian

Below are examples of using SQL to return the first day of the month across various DBMSs.

This could be the first day of the current month, or the first day of a month based on a given date.

Continue reading →
MariaDB, MySQL, Oracle, PostgreSQL, SQL, SQL Server, SQLite dates, how to

Subtract Months from a Date in SQLite

Posted on September 4, 2022 by Ian

In SQLite, we can use the DATE() function to subtract one or more months from a date.

For datetime values, we can use the DATETIME() function.

Continue reading →
SQLite dates, how to

SQLite CASE Expression

Posted on September 2, 2022 by Ian

In SQLite, the CASE expression compares a list of conditions and returns one of multiple possible expressions.

The CASE expression is included in the SQL standard (ISO/IEC 9075), and most major RDBMSs support it.

Continue reading →
SQLite operators, what is

Get the First, Second, Third, or Fourth Monday of a Year in SQLite

Posted on August 30, 2022 by Ian

We can use SQLite’s DATE() function to return the first, second, third, fourth, etc instance of a given day within a given year.

We can use the same technique to return the first Monday of each month in the year.

It’s not limited to Monday though. The same techniques can be used on Tuesday, Wednesday, Thursday, Friday, etc.

Continue reading →
SQLite dates, how to

Subtract Seconds from a Time Value in SQLite

Posted on August 8, 2022 by Ian

In SQLite, we can use the TIME() function to subtract one or more seconds from a time value.

For datetime values, we can use the DATETIME() function.

Continue reading →
SQLite dates, how to

How to Delete Duplicate Rows that have a Primary Key in SQL

Posted on August 3, 2022September 20, 2024 by Ian

The following examples use SQL to delete duplicate rows that have a primary key or unique identifier column.

Specifically, the examples delete all duplicates except one. So for example, in the case of three identical rows, it deletes two of them and keeps one.

Continue reading →
MariaDB, MySQL, Oracle, PostgreSQL, SQL, SQL Server, SQLite how to

Fix “cannot add a STORED column” in SQLite

Posted on July 30, 2022 by Ian

If you’re trying to add a generated column in SQLite, and you’re getting the “cannot add a STORED column” error, it’s probably because you’re trying to add a stored column.

In SQLite, we can only add virtual columns to existing tables.

Continue reading →
SQLite computed columns, how to

Return Rows that Contain Only Non-Alphanumeric Characters in SQL

Posted on July 24, 2022 by Ian

Here are examples of using SQL to return rows that contain non-alphanumeric characters in various DBMSs.

Non-alphanumeric characters include punctuation characters like !@#&()–[{}]:;',?/* and symbols like `~$^+=<>“, as well as whitespace characters like the space or tab characters.

Continue reading →
MariaDB, MySQL, Oracle, PostgreSQL, SQL, SQL Server, SQLite how to

Subtract Hours from a Time Value in SQLite

Posted on July 15, 2022 by Ian

In SQLite, we can use the TIME() function to subtract one or more hours from a time value.

For datetime values, we can use the DATETIME() function.

Continue reading →
SQLite dates, how to

Return Only Numeric Values in SQL

Posted on July 5, 2022 by Ian

If you ever need to use SQL to return just the numeric values in a character column, the method you use will largely depend on your DBMS. Most DBMSs support regular expressions (regex), but some don’t. And some include functions that can detect numeric values.

Here are examples of how to do it in the more popular DBMSs.

Continue reading →
MariaDB, MySQL, Oracle, PostgreSQL, SQL, SQL Server, SQLite how to
  • «
  • 1
  • …
  • 6
  • 7
  • 8
  • 9
  • 10
  • …
  • 30
  • »

About Database.Guide | Privacy Policy