MySQL中的分段组
如何将 MySQL 表中的连续数据分组并将其数量存储到额外的列中?
例如:
id, n
1 10
2 10
3 10
4 56
5 10
6 10
7 80
8 12
我想要得到这样的东西。请注意,n of 10 被列出了两次。
id n cnt
1 10 3
4 56 1
5 10 2
7 80 1
8 12 1
有没有办法在没有 FUNCTION 的情况下做到这一点?
How I can to group continuous data in MySQL table and store its number to an extra column?
For example:
id, n
1 10
2 10
3 10
4 56
5 10
6 10
7 80
8 12
I want to get something like this. Notice that n of 10 is listed twice.
id n cnt
1 10 3
4 56 1
5 10 2
7 80 1
8 12 1
Is that any way to do this without FUNCTION?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 MySQL 变量
You can with use of MySQL Variables