Lesson 5 | Formatting numeric columns |
Objective | Control the display of numeric columns. |
Character | Description | If you use this format specification | To display this value | The output will look like this. |
---|---|---|---|---|
9 | "9"s are used to represent digits in the output | 999 999999 | 123 123 | 123 123 |
0 | Same as 9, but does not suppress leading zeros | 099 099999 990999 | 123 123 123 | 123 000123 0123 |
. | Marks the decimal point | 999.99 | 123.45 | 123.45 |
, | Marks the location of commas in the output | 999,999.99 | 123456.78 | 123,456.78 |
$ | Places a leading dollar sign in the output | $999,999.99 | 123456.78 | $123,456.78 |
PR | Causes negative numbers to display in parentheses | (999.99) | -123 | (123.45) |
S | Forces a sign to be displayed, even for positive numbers. May be placed at either end of the number. | S999 999s | -123 123 | -123 123+ |
SQL> COLUMN a FORMAT 999,999.99 SQL> COLUMN b FORMAT 099,999.99 SQL> COLUMN c FORMAT $999,999.99 SQL> SELECT 123.45 a, 2 234.56 b, 3 345.67 c 4 FROM dual; A B C ----------- ----------- ------------ 123.45 000,123.45 $123.45