Mysql统计id查询
我正在使用这样的 mysql 表:
| userid | regdate | question | answer |
-----------------------------------------------
1 2010-10-14 question 1 answer1
2 2010-10-14 question 2 answer2
3 2010-10-15 question 3 answer3
4 2010-10-16 question 4 answer4
我想计算每天的注册用户数以及每天发送的问题和答案的数量。我可以用一个 mysql 查询来完成它吗?如何做?
结果应该是这样的:
| regdate | new users | questions sent | answers sent |
--------------------------------------------------------------
2010-10-14 2 2 2
2010-10-15 1 1 1
2010-10-16 1 1 1
I'm using mysql table like this one:
| userid | regdate | question | answer |
-----------------------------------------------
1 2010-10-14 question 1 answer1
2 2010-10-14 question 2 answer2
3 2010-10-15 question 3 answer3
4 2010-10-16 question 4 answer4
I want to count registered users per day and the number of questions and answers sent per day. Can I do it with one mysql query and how?
The result should be something like:
| regdate | new users | questions sent | answers sent |
--------------------------------------------------------------
2010-10-14 2 2 2
2010-10-15 1 1 1
2010-10-16 1 1 1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许:
我不确定,因为,你的意思是“新注册用户”还是“登录用户”?另外,从你的表格来看,用户似乎必须为每个问题发送答案,我怀疑情况确实如此......
maybe:
I am not sure though because, do you mean "newly registered users" or "logged in users" ? Also, from your table, it looks like a user has to send an answer for each question, which I doubt is the case...
试试这个
Try this