Curriculum
Course: MYSQL
Login

Curriculum

MYSQL

MySQL References

0/140
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.56342); 

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(numberdecimal_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.56340);