我试图累计计算用户注册数量,我的数据与此类似:
User_ID Creation Date
2 11-02-2017
3 10-25-2017
4 10-22-2017
5 10-20-2017
6 10-14-2017
7 10-02-2017
8 10-01-2017
我想要一个查询,显示在表格中每个日期之前注册的用户数量,如:
Registrations Creation Date Accumulated
1 11-02-2017 1
1 10-25-2017 2
1 10-22-2017 3
1 10-20-2017 4
1 10-14-2017 5
1 10-02-2017 6
1 10-01-2017 7
我目前的查询是:
SELECT count(*) as total,
date(created_at) as date,
@running_count := @running_count + count(*) AS Counter
FROM Users
GROUP BY date
不幸的是它不起作用,任何人都能解释一下吗?
PS:请不要链接显示如何对字段值求和的问题,因为这是对COUNT行进行求和。
答案 0 :(得分:0)
您需要在子查询中进行分组。
<section class="container about-container">
<div class="about-author col col-2-3">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ab nesciunt voluptatum sunt explicabo similique quam tempora fugiat laborum aliquid cupiditate, earum quo, pariatur voluptates delectus corporis quos et vero quia.</p>
</div>
<div class="image-author col col-1-3"><img src="http://via.placeholder.com/260x280" alt="sudipto-das"></div>
</section>