SQL Number Format
Here’s an example:
SELECT FORMAT(1, 'N');
Result:
1.00
In this case, I used N as the second argument. This is the standard numeric format specifier for Number. This particular format specifier (N) results in the output being formatted with integral and decimal digits, group separators, and a decimal separator with optional negative sign. This argument is case-insensitive, so either N or n is fine.
Decimal Places
Here’s another example, this time using N1 to specify that we only want one decimal place:
SELECT FORMAT(1, 'N1');
Result:
1.0
But you can also increase the number of decimal places too:
SELECT FORMAT(1, 'N7');
Result:
1.0000000
Comments
Post a Comment