在DB2中转换为货币或货币格式 [英] Convert to currency or money format in DB2

查看:605
本文介绍了在DB2中转换为货币或货币格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一列数据类型 dec(16,2),可能的值如 20000.00
我想要结果以逗号分隔的货币或货币格式,如下所示: 20,000.00

I have a column of datatype dec (16,2) with a possible value like 20000.00. I want the result in comma-separated currency or money format like this: 20,000.00.

As现在我打算把这个除以1000,并用逗号分隔。但是我想知道DB2是否有内置的功能来隐藏这个。或任何其他更简单的方法来将整数转换为货币格式。

As of now I am planning to divide this by 1000's and concat with comma. But I want to know if DB2 has an inbuilt functionality to covert this. Or any other easier method to convert integer to currency format.

select A.Billing_Amount 
from Transaction_Table A with ur;


推荐答案

您可以创建一个独特的UDT来将列存储为货币类型如下:

You can create a distinct UDT to store the column as currency type like the following:

 CREATE DISTINCT TYPE CURRENCY AS DEC(15,2) WITH COMPARISONS;

这篇关于在DB2中转换为货币或货币格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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