MariaDB 10.6 整数をカンマ区切りで出力する

環境
Windows 10 Home 64bit
MariaDB 10.6.4

書式
FORMAT( 数値,少数以下の桁数 )
少数以下の桁数を「0」に指定して「FORMAT( )」を使用して整数をカンマ区切りで出力します。

使用例1
桁数を「0」に指定します
SQl構文
SELECT FORMAT( 1234500,0 ) result;

実行結果

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
MariaDB [(none)]> SELECT FORMAT( 1234500,0 ) result;
+-----------+
| result |
+-----------+
| 1,234,500 |
+-----------+
1 row in set (0.035 sec)
MariaDB [(none)]> SELECT FORMAT( 1234500,0 ) result; +-----------+ | result | +-----------+ | 1,234,500 | +-----------+ 1 row in set (0.035 sec)
MariaDB [(none)]> SELECT FORMAT( 1234500,0 ) result;
+-----------+
| result    |
+-----------+
| 1,234,500 |
+-----------+
1 row in set (0.035 sec)

使用例2
「マイナス」を指定します
SQL構文
SELECT FORMAT( -1234500,0 ) result;
実行結果

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
MariaDB [(none)]> SELECT FORMAT( -1234500,0 ) result;
+------------+
| result |
+------------+
| -1,234,500 |
+------------+
1 row in set (0.000 sec)
MariaDB [(none)]> SELECT FORMAT( -1234500,0 ) result; +------------+ | result | +------------+ | -1,234,500 | +------------+ 1 row in set (0.000 sec)
MariaDB [(none)]>  SELECT FORMAT( -1234500,0 ) result;
+------------+
| result     |
+------------+
| -1,234,500 |
+------------+
1 row in set (0.000 sec)

 

MariaDB

Posted by arkgame