Returns character data converted from numeric data.
STR ( float_expression [ , length [ , decimal ] ] )
- Is an expression of that can be implicitly converted to float.
Note Do not use a function or subquery as the float_expression.
- Is the total length, including decimal point, sign, digits, and spaces. The default is 10. length must be of a data type that can be implicitly converted to int.
- Is the number of places to the right of the decimal point. decimal must be of a data type that can be implicitly converted to int. The default is 0.
The following example converts expressions consisting of five digits and a decimal point to six-position character strings. The fractional part of the first number is rounded to one decimal place. The fractional part of the second number is rounded to two decimal places. The third number is returned without a decimal place.
CREATE TABLE t1 (Col1 float, Col2 float, Col3 float) INSERT INTO t1 Values(123.45, 123.45, 123.45) SELECT STR(Col1, 6,1), STR(Col2, 6,2), STR(Col3) FROM t1