Skip to main content

FORMAT

Description​

Returns a formatted string using the specified format string and arguments:

Syntax​

FORMAT(<format>, <args> [, ...])

Parameters​

ParameterDescription
<format>The value is to be format mode
<args>The value is to be format within string

Return Value​

The formatted string using a format mode.

Example​

select format("{:.5}",pi());
+-----------------------+
| format('{:.5}', pi()) |
+-----------------------+
| 3.1416 |
+-----------------------+
select format("{:08.2}",pi());
+-------------------------+
| format('{:08.2}', pi()) |
+-------------------------+
| 000003.1 |
+-------------------------+
select format("{0}-{1}","second","first");
+--------------------------------------+
| format('{0}-{1}', 'second', 'first') |
+--------------------------------------+
| second-first |
+--------------------------------------+