行&总和列
我有一个非常复杂的查询(mysql + php),我想知道除了使用 SUM(x) 之外对表的列和行求和的最简单方法。
也许 JavaScript 可以提供帮助。 提前致谢。
i have a really complex query (mysql + php) and i would like to know the easiest way to sum columns and rows of a table apart from using SUM(x).
Maybe a javascript could help.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我建议使用 MySQL 中的 SUM() 函数。不使用它的唯一原因是如果您有一些基于其他值的复杂计数。然后我会在 PHP 中进行计数。这是一个例子:
I would advise to use the SUM() function in MySQL. The only reason to not use it is if you have some complicated counting based on other values. Then I would do the counting in the PHP. Here is an example:
我会在查询本身中执行此操作。如果您发布查询,我可以提供更多信息。
I would do this in the query itself. If you post the query, I can provide more information.
这是查询,我想对列和行求和。 (行是一年中每个月订购的变量“svago”和“lavoro”,而列是全年的相同值)
This is the query, i want to sum cols and rows. ( rows are the vars "svago" and "lavoro" ordered for each month of the year, while cols are the same values in the whole year )