如何在PostgreSQL中格式化货币 [英] How to format money in PostgreSQL
本文介绍了如何在PostgreSQL中格式化货币的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含(例如)1234.5678的浮点字段。我想将其显示为1 234.56或1 234,56。我该怎么做?
I have float field that contains (for example): 1234.5678. I would like to display it like a 1 234.56 or 1 234,56. How can I do that?
我使用了 to_char()
函数,该函数可以给我:
I used to_char()
function that gives me:
SELECT to_char(12345.5678,'99999999999999999D99');
-> 12345,57
但是,当我的值为零时...
but, when I have zero-value...
SELECT to_char(0,'99999999999999999D99');
-> ,00
推荐答案
内部零:
SELECT to_char(0,'99999999999999990D99');
-- Second question from the comments: Howto make k-seperator
SELECT to_char (1234567890999999.8,'99 999 999 999 999 990D99');
这是在线数独:函数(数据类型转换)。也许您想下载它。
Here is the online-doku: functions (data-type conversion). Maybe you like to download it.
这篇关于如何在PostgreSQL中格式化货币的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文