如何在 postgresql 中删除 money 数据类型的精度部分?
How to remove precision part of money datatype in postgresql?
我在 money 列有一些数据,数据库是 postgrsql,默认两位小数进入 select 查询结果,我可以截断或替换最后三个字符来实现我的目标,有没有功能或其他有效的方法。
select mycolumn from mytable;
output is 6,352.00
output should be 6,352
转换为数字类型,然后可以使用to_char()
函数格式化值:
select to_char(mycolumn::numeric, '$FM999,999')
from mytable
to_char()
为您提供了广泛的格式设置选项。有关详细信息,请参阅 the manual。
我在 money 列有一些数据,数据库是 postgrsql,默认两位小数进入 select 查询结果,我可以截断或替换最后三个字符来实现我的目标,有没有功能或其他有效的方法。
select mycolumn from mytable;
output is 6,352.00
output should be 6,352
转换为数字类型,然后可以使用to_char()
函数格式化值:
select to_char(mycolumn::numeric, '$FM999,999')
from mytable
to_char()
为您提供了广泛的格式设置选项。有关详细信息,请参阅 the manual。