【发布时间】:2015-09-11 10:48:40
【问题描述】:
我有这张桌子:
id
entry_date (timestamp)
exit_date (timestamp)
我需要显示每天的累积差异。实际上是平均的,但至少是累积的。
所以输出将如下所示:
2015 1 1 33
2015 1 3 56
2015 2 4 77
2015 3 12 123
意义
Year month day cummulative_sum(exit_date-entry_date).
我检查过类似的主题:
MySQL cumulative sum grouped by date
Cumulative sum over a set of rows in mysql
Optimal query to fetch a cumulative sum in MySQL
Create a Cumulative Sum Column in MySQL
但是没有一个解决方案对我有用。我越来越不顾一切地只用 SQL 来做到这一点。 但是这些任务听起来很简单,以至于很难相信解决方案很难找到。
【问题讨论】:
标签: mysql group-by sum average