How to Format Numbers in MariaDB

MariaDB has the FORMAT() function, which formats a number based on the given format string.

It returns the number as a formatted string, with thousands and decimal separators in the appropriate position and rounds the result to the specified decimal position.

You can optionally specify a locale value to format numbers to the pattern appropriate for the given region.

Read more

How to Concatenate Strings in SQL

Most of the major RDBMSs provide several options for concatenating two or more strings.

  • There’s the CONCAT() function, which concatenates its arguments.
  • There’s also a CONCAT_WS() that allows you to specify a separator that separates the concatenated strings.
  • And there’s also a string concatenation operator, which allows us to concatenate its operands.

Below are examples of each method.

Read more

Format Numbers with Commas in PostgreSQL

In PostgreSQL, we can use the TO_CHAR() function to format numbers in a given format. This includes formatting numbers with commas in the relevant location.

PostgreSQL also has a money data type, which outputs the value using the current locale. This can include commas in the appropriate place, based on the locale being used.

Read more

Format Numbers with a Comma in SQLite

SQLite has a printf() function or format() function that allows us to format numbers according to a format string.

As from SQLite 3.18.0, it accepts a comma flag, which enables us to have comma separators at the thousands marks for integers.

Further work can be done to get it working with real/floating point numbers.

Read more