Skip to content

SQL Bits

You're here to find quick SQL recipes.

  • Home
  • Topics
    • Generic SQL
    • PostgreSQL
    • MariaDB
    • MySQL
    • Oracle
    • SQL Server
    • Db2
    • Informix
    • SQLite
  • Advertising
  • Write
  • About

Create a cross-table unique ID

Most tables are created with a unique, progressive ID. But how to create an ID whose values are unique across multiple tables? For example, if value 1 is in table A, it must not be in table B.

Continue reading Create a cross-table unique ID
Published July 23, 2021
Categorized as Db2, Generic SQL, Informix, MariaDB, Oracle, PostgreSQL, SQL Server Tagged level-intermediate

Find invalid emails

How to select invalid email addresses from a column. How to reject attempts to insert invalid emails into a column.

Continue reading Find invalid emails
Published July 23, 2021
Categorized as Generic SQL Tagged level-beginner

MariaDB: Select the Fibonacci series

How to select the first N numbers from the Fibonacci series, or the Nth number from the series. This is done by using the SEQUENCE storage engine and user variables.

Continue reading MariaDB: Select the Fibonacci series
Published July 22, 2021
Categorized as MariaDB Tagged level-expert

Aggregate a column data

How to get statistical data from a column in standard SQL. In particular it shows how to get the minimum, maximum, average values, and the standard deviation.

Continue reading Aggregate a column data
Published July 22, 2021
Categorized as Generic SQL, SQLite Tagged level-beginner

Find values (not) in a given range

How to use the special SQL syntax to select rows with values in a given range, or outside of it. How to deal with bounds in a reversed order.

Continue reading Find values (not) in a given range
Published July 22, 2021
Categorized as Generic SQL Tagged level-beginner

Count a table rows

How to count a table rows, a table distinct rows, a column values, missing values, etc.

Continue reading Count a table rows
Published July 22, 2021
Categorized as Generic SQL Tagged level-beginner

Posts navigation

Newer posts Page 1 … Page 7
  • Twitter
  • Email
SQL Bits
Proudly sponsored by Vettabase.