mysql 嵌套计数 - 如何?
这是初始查询:从表 GROUP BY 列中选择 COUNT(列);
这给了我类似以下内容:COUNT(列)
2
4
1
1
3
等等
但我需要将所有这些都算在一个数字中!我怎么能这么做呢? COUNT(COUNT(column))
抛出错误:“组函数的使用无效”。
PS 这不会在任何程序中使用,如果使用的话,将它们一起计数将是微不足道的。
Here's the initial query:SELECT COUNT(column) FROM table GROUP BY column;
This gives me something like the following:COUNT(column)
2
4
1
1
3
etc.
BUT I need to to count all of those together in one number! How could I do that? COUNT(COUNT(column))
throws an error: "Invalid use of group function".
P.S. this is not used in any program, if it was, it would be trivial to count them together.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
删除分组依据:
如果您需要不同的列:
或:
remove the group by:
if you need distinct columns:
or:
不确定这在 mysql 中是否有效:SELECT COUNT(distinct column) FROM table
Not sure if this works in mysql: SELECT COUNT(distinct column) FROM table