十进制格式化在sql查询 [英] decimal formatting in sql query

查看:584
本文介绍了十进制格式化在sql查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个查询如下:

 从myTable中选择价格; 

返回值'.22 .50'



但是,我的程序中需要格式为 5.8 bytes



这是我的字符串值应为'00022.50000000'而不是'.22 .50'



有没有办法在SQL中直接实现?

解决方案

从文档,我认为您希望 CHAR DECIMAL (22.50,13,8))



我没有DB2实例玩,所以无法验证。这些功能不是 ANSI SQL ,它们是DB2特定的。 / p>

I have a query as below:

Select price from myTable;

This returns value '22.50'

However, I need the format as 5.8 bytes in my program.

That is my String value should be '00022.50000000' and not '22.50'

Is there a way to achieve this directly in SQL ?

解决方案

From docs, I think you want CHAR( DECIMAL( 22.50, 13, 8 ) )

I have no DB2 instance to play with so can't verify. These functions are not ANSI SQL, they are DB2 specific.

这篇关于十进制格式化在sql查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆