Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

FORMAT

Example

Format the number to display with commas separating every three digits, and round it to two decimal places.

SELECT FORMAT(250500.5634, 2); 

Definition and Usage

The FORMAT() function formats a number into a specific format, such as “#,###,###.##”, with rounding to a specified number of decimal places, and returns the result as a string.

Syntax

FORMAT(number, decimal_places)

Parameter Values

Parameter

Description

number

Necessary: The number that requires formatting.

decimal_places

Necessary: The number of decimal places to be included in the formatted number. If set to 0, the function returns a string without decimal places.

Technical Details

Works in: From MySQL 4.0

More Examples

Example

Format the number according to the pattern “#,###,###.##” with no decimal places.

SELECT FORMAT(250500.5634, 0);