Reputation: 385
select round(836.0) returns 836.0
How can i remove the trailing zeroes in an sqlite query.
836.00 should be 836 836.440 should be 836.44
Upvotes: 2
Views: 2751
Reputation: 4035
For small numbers, you can use the %g
option of printf()
, together with round()
.
select round(25.999, 2); --- prints "26.0"
select printf("%g", round(25.999, 2)); --- prints "26"
Upvotes: 1
Reputation: 175816
If you want 836.44
you need a decimal return type, 836
expressed in this way will always have a .00
. 836
on its own would need to be an integer and you cannot mix types in a column like that.
Your only option would be to use a string return type and remove .0*
select rtrim(rtrim(round(FLD, 2), '0'), '.')
Instead, this is best done in your presentation layer.
Upvotes: 3