str 函数 将小数转换为varchar类型
2015-10-26 12:45
435 查看
When you want to convert from float or real to character data, using the STR string function is usually more useful than CAST( ). This is because STR enables more control over formatting.
Syntax
Arguments
float_expression
Is an expression of approximate numeric (float) data type with a decimal point.
length
Is the total length. This includes decimal point, sign, digits, and spaces. The default is 10.
decimal
Is the number of places to the right of the decimal point. decimal must be less than or equal to 16. If decimal is more than 16 then the result is truncated to sixteen places to the right of the decimal point.
Return Type
Varchar,
To convert to Unicode data, use STR inside a CONVERT or CAST conversion function
示例
结果是 123.5,类型是Varchar
Syntax
STR ( float_expression [ , length [ , decimal ] ] )
Arguments
float_expression
Is an expression of approximate numeric (float) data type with a decimal point.
length
Is the total length. This includes decimal point, sign, digits, and spaces. The default is 10.
decimal
Is the number of places to the right of the decimal point. decimal must be less than or equal to 16. If decimal is more than 16 then the result is truncated to sixteen places to the right of the decimal point.
Return Type
Varchar,
To convert to Unicode data, use STR inside a CONVERT or CAST conversion function
示例
SELECT STR(123.45, 6, 1);
结果是 123.5,类型是Varchar
相关文章推荐
- Python二维码生成库qrcode安装和使用示例
- 开篇
- Android多媒体编程——图片的大小计算
- Mac下 android 模拟器/真机 host修改
- HTML基础(登录按钮如何改样式)
- ShortestPath:Silver Cow Party(POJ 3268)
- linux 下的socket 客户端开发
- 自定义progressdialog加载动画,这里还有旋转的加载条,美团,多个图片动画
- RTS与CTS的含义
- Boost.asio 一些注意事项
- messagepcak 资料
- Android Activity之 setContentView()总结
- 部分面试题
- Android DEX安全攻防战
- 散列表
- tips for configuring your .vimrc
- 关于面试和招聘,我自己的规划
- ios如何获取xib自动布局后视图的宽度和高度
- Android APK加壳技术方案【2】
- Virtualbox WDDM之DxgkDdiQueryDeviceDescriptor