MySQL - 千位分隔符
我想知道是否有办法在 SQL 查询中获取千位分隔符?
请求如下所示:
select coalesce(user, 'TOTAL') as "user",
concat(count(items), ' items') as "nb_items",
concat(replace(sum(amount), '.', ','), ' €') as "total_in_euro",
concat(
round((sum(amount) / (select sum(amount) from my_db) * 100), 2),
' %'
) as "share"
from my_db
group by user
with rollup
目前,CSV 结果是:
user;nb_items;total_in_euro
usr_1;20 items;20000 €;10,01 %
usr_2;254 items;17852,12 €;8,12 %
我想要的是这样的结果:
user;nb_items;total_in_euro
usr_1;20 items;20 000 €;10,01 %
usr_2;254 items;17 852,12 €;8,12 %
有办法做到这一点吗?
I would like to know if there is a way to get a thousand separator in an SQL Query ?
The request looks like this :
select coalesce(user, 'TOTAL') as "user",
concat(count(items), ' items') as "nb_items",
concat(replace(sum(amount), '.', ','), ' €') as "total_in_euro",
concat(
round((sum(amount) / (select sum(amount) from my_db) * 100), 2),
' %'
) as "share"
from my_db
group by user
with rollup
Currently, the CSV result is:
user;nb_items;total_in_euro
usr_1;20 items;20000 €;10,01 %
usr_2;254 items;17852,12 €;8,12 %
What I want is a result like that :
user;nb_items;total_in_euro
usr_1;20 items;20 000 €;10,01 %
usr_2;254 items;17 852,12 €;8,12 %
Is there a way to do so ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道如何用空格来实现,但标准(用点或逗号 [德国即])分隔可以通过
FORMAT()
实现。查看格式化函数
I don't know how to do it with a space, but the standard (with a point or a comma [germany i.e.]) seperation can be achieved with
FORMAT()
.Have a look at the Format Function