Remove (.) from decimal values in postgres
I want to remove . from all decimal value from my query output like if i use
select(32.00) output should come 3200
select(32.50) output should come 3250
select(32.05) output should come 3205
Is there is any function 开发者_如何学Pythonpresent to give me this output i dont want 3200.00 as output if anyone know plz tell me how ?
You could multiply by 100 and cast to an integer:
=> select cast(32.00*100 as integer);
int4
------
3200
That will give you an integer. If your values aren't the decimal(n,2) that they appear to be, then you might want to pull out round, floor, or ceil to make your desired rounding or truncation explicit:
=> select floor(23.025 * 100), ceil(23.025 * 100), round(23.025 * 100);
floor | ceil | round
-------+------+-------
2302 | 2303 | 2303
You could try:
SELECT replace(CAST(your_field AS text),'.','')
FROM your_table
加载中,请稍侯......
精彩评论