从postgres中的十进制值中删除(.)

Dee*_*mar 0 sql postgresql

我想删除.从我的查询输出中的所有十进制值,如果我使用

select(32.00) output should come 3200
select(32.50) output should come 3250
select(32.05) output should come 3205
Run Code Online (Sandbox Code Playgroud)

有没有任何功能给我这个输出我不想要3200.00作为输出,如果有人知道PLZ告诉我如何?

mu *_*ort 10

您可以乘以100并转换为整数:

=> select cast(32.00*100 as integer);
 int4 
------
 3200
Run Code Online (Sandbox Code Playgroud)

那会给你一个整数.如果你的价值观是不是decimal(n,2)他们似乎是,那么你可能要拔出来round,floor或者ceil让你的期望的舍入或截断明确:

=> select floor(23.025 * 100), ceil(23.025 * 100), round(23.025 * 100);
 floor | ceil | round 
-------+------+-------
  2302 | 2303 |  2303
Run Code Online (Sandbox Code Playgroud)