题目5:MySQL----------Consecutive Numbers
来源:互联网 发布:ubuntu不能创建文件夹 编辑:程序博客网 时间:2024/05/22 00:53
Write a SQL query to find all numbers that appear at least three times consecutively.
+----+-----+| Id | Num |+----+-----+| 1 | 1 || 2 | 1 || 3 | 1 || 4 | 2 || 5 | 1 || 6 | 2 || 7 | 2 |+----+-----+
For example, given the above Logs
table, 1
is the only number that appears consecutively for at least three times.
题目解答
# Write your MySQL query statement belowselect distinct Num from ( select Num, case when @prevNum = Num then @count := @count + 1 when (@prevNum := Num) is not null then @count := 1 end n from Logs, (select @prevNum := NULL) r order by Id) a where n >= 3
0 0
- 题目5:MySQL----------Consecutive Numbers
- MySQL-Consecutive Numbers
- LEETCODE SQL题目 180. Consecutive Numbers
- Consecutive Numbers
- Consecutive Numbers
- Consecutive Numbers
- Consecutive Numbers
- POJ 题目2739 Sum of Consecutive Prime Numbers(水题)
- LeetCode | Consecutive Numbers
- [leetcode] Consecutive Numbers
- consecutive numbers 180
- LeetCode:Consecutive Numbers
- Leetcode:Consecutive Numbers
- [LeetCode] Consecutive Numbers - SQL
- Leetcode: Consecutive Numbers
- [LeetCode][Database]Consecutive Numbers
- LeetCode OJ Consecutive Numbers
- LeetCode_OJ【180】Consecutive Numbers
- 点击超链接,不跳转界面
- android中子线程更新UI的方式浅析
- [数字图像处理]频域滤波(2)--高通滤波器,带阻滤波器与陷波滤波器
- github诞生记
- 题目4:MySQL----------Rank Scores
- 题目5:MySQL----------Consecutive Numbers
- 进制转换(itoa函数的使用)
- c语言学习笔记 之调用dll动态库
- Python模块卸载
- java中垃圾收集器的重点
- 黑马程序员——java集合框架
- C学习笔记(五)字符输入\输出
- 整型变量
- MySQL XML解析及數組處理