当前位置:网站首页>力扣(LeetCode)180. 连续出现的数字(2022.06.29)
力扣(LeetCode)180. 连续出现的数字(2022.06.29)
2022-06-30 04:55:00 【ChaoYue_miku】
表:Logs
±------------±--------+
| Column Name | Type |
±------------±--------+
| id | int |
| num | varchar |
±------------±--------+
id 是这个表的主键。
编写一个 SQL 查询,查找所有至少连续出现三次的数字。
返回的结果表中的数据可以按 任意顺序 排列。
查询结果格式如下面的例子所示:
示例 1:
输入:
Logs 表:
±—±----+
| Id | Num |
±—±----+
| 1 | 1 |
| 2 | 1 |
| 3 | 1 |
| 4 | 2 |
| 5 | 1 |
| 6 | 2 |
| 7 | 2 |
±—±----+
输出:
Result 表:
±----------------+
| ConsecutiveNums |
±----------------+
| 1 |
±----------------+
解释:1 是唯一连续出现至少三次的数字。
来源:力扣(LeetCode)
链接:https://leetcode.cn/problems/consecutive-numbers
方法一:使用DISTINCT
MySQL提交内容:
# Write your MySQL query statement below
SELECT DISTINCT
l1.Num AS ConsecutiveNums
FROM
Logs l1,
Logs l2,
Logs l3
WHERE
l1.Id = l2.Id - 1
AND l2.Id = l3.Id - 1
AND l1.Num = l2.Num
AND l2.Num = l3.Num
;
边栏推荐
- Singapore must visit these scenic spots during the Spring Festival
- IIS request SSL certificate
- Create a simple battle game with photon pun
- How to renew an SSL certificate
- 【Paper】2019_ Distributed Cooperative Control of a High-speed Train
- [UAV] gyroscope data analysis, taking Victor intelligent jy901b as an example
- Unit screenshot saved on the phone
- 【Paper】2006_ Time-Optimal Control of a Hovering Quad-Rotor Helicopter
- [control] multi agent system summary. 5. system consolidation.
- svg和canvas的区别
猜你喜欢

力扣27. 移除元素

Wildcard SSL certificate issuing time

Unity Logitech steering wheel access

【Paper】2013_ An efficient model predictive control scheme for an unmanned quadrotor helicopter
![[UAV] kinematic analysis from single propeller to four rotor UAV](/img/32/1a88b102f832ffbbc1a7e57798260a.jpg)
[UAV] kinematic analysis from single propeller to four rotor UAV

Sailing experience not to be missed in New York Tourism: take you to enjoy the magnificent city scenery from different perspectives

UE4 method of embedding web pages

SCM learning notes: interrupt learning

Detailed explanation of the process of "flyingbird" small game (camera adjustment and following part)

力扣704. 二分查找
随机推荐
【Paper】2019_ Consensus Control of Multiple AUVs Recovery System Under Switching Topologies and Time D
National Museum of Singapore - give you spiritual and physical satisfaction
力扣周赛293题解
Universal Studios Singapore: a good place for a one-day parent-child tour in Singapore
Method of applying for code signing certificate by enterprise
Solution to the 292 week match of Li Kou
How to apply for SSL certificate from the manufacturer
Pourquoi l'ordinateur n'a - t - il pas de réseau après l'ouverture du Hotspot win10?
Free travel recommendation in Bangkok: introduction to the Mekong River in Bangkok
0 basic unity course. Bricklaying
Connect to the database and run node JS running database shows that the database is missing
Unity automatic pathfinding
Redis implements SMS login function (II) redis implements login function
UE4 method of embedding web pages
Have a heart beating Valentine's day in Singapore
Is the Flink connector JDBC open source? Where can I download it
Marvel fan welfare: Singapore Madame Tussauds Wax Museum Marvel 4D experience Museum
Paging query, using jdbc-- paging query
【Paper】2021_ Analysis of the Consensus Protocol of Heterogeneous Agents with Time-Delays
力扣292周赛题解