如何在PostgreSQL中格式化钱

Bal*_*ald 3 postgresql

我有浮点字段包含(例如):1234.5678.我想把它显示为1 234.56或1 234,56.我怎样才能做到这一点?

我使用的to_char()函数给了我:

SELECT to_char(12345.5678,'99999999999999999D99');
-> 12345,57
Run Code Online (Sandbox Code Playgroud)

但是,当我有零价值时......

SELECT to_char(0,'99999999999999999D99');
-> ,00
Run Code Online (Sandbox Code Playgroud)

use*_*own 5

内部为零:

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');
Run Code Online (Sandbox Code Playgroud)

这是online-doku:函数(数据类型转换).也许你想下载它.