Convert to currency or money format in DB2

断了今生、忘了曾经 提交于 2019-12-12 21:40:11

问题


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 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;

回答1:


You can also try:

 select decimal(A.Billing_Amount,9,2) from Transaction_Table A with ur;



回答2:


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;


来源:https://stackoverflow.com/questions/29852504/convert-to-currency-or-money-format-in-db2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!