float_expression is an expression of float data type with a decimal point.
length is total length including decimal point, sign, digits, and spaces. The default is 10. If you specify negative value then it returns NULL. It should be greater than or equal to the part of the number before the decimal point plus it's sign. If it is not so then it returns ** .
decimal is the number of places after decimal point. If you specify negative value then it returns NULL.
Return type of STR function is char.
Examples of STR function :
Example 1 : Use of STR function in select clause
SELECT STR(137.45,7,3)
Output
137.450
Above example can displays 6 digits and a decimal point as seventh character. Fractional part of the number is rounded to three decimal places.
Example 2 : Converting negative number to character type using STR function
SELECT STR(-137.45,6,1)
Output
-137.4
Above example displays 4 digits, 5th character as negative sign and 6th character as decimal point. Fractional part of the number is rounded to one decimal place.