将数字:103,648.340
格式化为预期结果
预期结果:103 648.34
我的进展:
SELECT
TRIM(price)+0 as price_without_decimal_zeros,
FORMAT(price, 1, 'bg_BG') as thousand_delimited_by_space
from products
TRIM
删除十进制零,所以我有103,648.34
FORMAT
添加以空格分隔的千位,所以我有103 648.340
我试过把TRIM
和FORMAT
结合起来,但没有成功
试试这个解决方案:
SELECT TRIM(TRAILING '.' FROM TRIM(TRAILING '0' from REPLACE(format(price, 3), ",", " ") )) AS price
FROM products
WHERE price LIKE '%.%'
演示