MySQL 连续日期序列的实现
我需要一个 MySQL 实现来回答这个问题:
我有完全相同的问题 - 但(据我了解)MySQL 不支持 DENSE_RANK()
或 ROW_NUMBER()
如果有人能指出我的正确方向方向,那就太好了。我尝试使用此处找到的基于月份的查询版本: forums.mysql.com:按连续日期分组 和 此处,但是查询陷入了 6,000 个“用户”的 300,000 条不太连续的记录,
非常感谢
I need a MySQL implementation of the brilliant code answering this question:
I have the exact same problem - but (as I understand it) MySQL does not support DENSE_RANK()
or ROW_NUMBER()
If anyone could point me in the right direction, that would be great. I have tried using a month-based version of the query found here: forums.mysql.com: Group By Consecutive Dates and here and but the query bogs down on 300,000 not very consecutive records for 6,000 'users'
Thanks muchly
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的。因此,除了“自上次范围结束以来的月份”字段之外,这个答案应该为您提供所需的一切。也许您可以在此基础上自行解决;-)。我已将
#data
表(在连续的日期序列帖子中提到)重命名为payment
:就像我说的 - 它不会给你从最后一个范围结束,但我认为答案的一部分总比没有好!
OK. So this answer should give you everything you need apart from the 'months since last range end' field. Maybe you can build on it and figure it out yourself ;-). I've renamed the
#data
table (referred to in the Consecutive Streak of Dates post) as aspayment
:Like I said - it won't give you the interval since last range end but I figured that part of an answer was better than none!