SQL 在整数值上添加逗号分隔符

发布于 2024-11-29 02:03:28 字数 360 浏览 3 评论 0原文

我有一个查询:

select sum(invoiceamount) as invoice
from fact_salescount
where year in ({YEAR})
and month >= ({FROMMONTH})
and month <= ({TOMONTH})

此查询可以返回 100.00 到 15034115.93 之间的值。它将返回 ONE 值。 我想为每个 000 添加这样的内容:15,034,115.93

我见过很多类似的问题,但没有一个与我的问题相符。我希望有人能帮助我。

我正在使用 Pentaho 和 MySQL,并在 Design Studio 中创建这些查询。

I have a query:

select sum(invoiceamount) as invoice
from fact_salescount
where year in ({YEAR})
and month >= ({FROMMONTH})
and month <= ({TOMONTH})

This query can return a value from 100.00 to 15034115.93. It will return ONE value.
I would like to add, for each 000, like this: 15,034,115.93

I've seen a lot of similar questions, but none match mine. I hope someone can help me out.

I am using Pentaho and MySQL, and creating these queries within the Design Studio.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

杀お生予夺 2024-12-06 02:03:28
SELECT FORMAT(sum(invoiceamount),2)
FROM fact_salescount
WHERE year IN ({YEAR})
AND month >= ({FROMMONTH})
AND month <= ({TOMONTH})

这应该可以满足您的要求,但我仍然不喜欢在后端格式化数字。

SELECT FORMAT(sum(invoiceamount),2)
FROM fact_salescount
WHERE year IN ({YEAR})
AND month >= ({FROMMONTH})
AND month <= ({TOMONTH})

This should do what you want, but I still don't like formatting number in the backend.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文