当前位置:网站首页>Leetcode MySQL database topic 180
Leetcode MySQL database topic 180
2022-06-29 09:58:00 【Water like ice】
180.Consecutive Numbers
1、 Questions and answers
Write a SQL query to find all numbers that appear at least three times consecutively.
To write SQL Query to find all numbers that appear at least three times in a row
Table:Logs:
+----+-----+
| Id | Num |
+----+-----+
| 1 | 1 |
| 2 | 1 |
| 3 | 1 |
| 4 | 2 |
| 5 | 1 |
| 6 | 2 |
| 7 | 2 |
+----+-----+For example, given the above
Logstable, 1 is the only number that appears consecutively for at least three times.
for example , Give the above Logs surface ,1 Is the only number that appears at least three times in a row
+-----------------+
| ConsecutiveNums |
+-----------------+
| 1 |
+-----------------+ answer : select distinct log1.num as ConsecutiveNums
from Logs log1, Logs log2, Logs log3
where log3.id=log2.id+1 and log2.id=log1.id+1 and log1.num = log2.num and log2.num = log3.num;
2、 Summary of knowledge points
Verification steps : create table logs(
id int NULL,
num int NULL
);
insert into logs
values(1,1),(2,1),(3,1),(4,2),(5,1),(6,2),(7,2);
Knowledge point :
select ... asAs a namewhereCondition screening
边栏推荐
- Closed door cultivation (24) shallow understanding of cross domain problems
- 基于stm32标准库独立按键的多按键状态机的实现
- Implementation of multi key state machine based on STM32 standard library
- Automatic Multi-Organ SegmVentation on Abdominal CT With Dense V-Networks
- leetcode MYSQL数据库题目176
- Middle order traversal of Li Kou 94 binary tree
- Wechat applet implements the data listener watch, including the watch that destroys the watch and sub attributes
- leetcode MYSQL数据库题目181
- FreeRTOS(九)——队列
- LiferayPortal JSONWS反序列化漏洞(CVE-2020-7961)分析
猜你喜欢

Automatic Multi-Organ SegmVentation on Abdominal CT With Dense V-Networks

Kicad learning notes - shortcut keys

Implementation of multi key state machine based on STM32 standard library

UE4 compile a single file (VS and editor start respectively)

Closed door cultivation (24) shallow understanding of cross domain problems

Visual assist plug-in settings for UE4 vs

float 与 int 相乘产生的令人崩溃的“ 2.3 * 10 = 22 ”

Closed training (25) basic web security

CROSSFORMER: A VERSATILE VISION TRANSFORMER BASED ON CROSS-SCALE ATTENTION

Gross Tumor Volume Segmentation for Head and Neck Cancer Radiotherapy using Deep Dense Multi-modalit
随机推荐
c#判断数组是否包含另一个数组的任何项
1424. diagonal traversal II
Closed training (25) basic web security
2020-9-14 广告系统入门
Fully Automated Gross Tumor Volume Delineation From PET in Head and Neck Cancer Using Deep Learning
Student增删gaih
Summary of PHP memory horse technology research and killing methods
Wechat applet implements the data listener watch, including the watch that destroys the watch and sub attributes
監控數據源連接池使用情况
2020-09-29 非商品模板化代码层次 rapidjson库
基于PyQt5和Qt Designer的简易加法计算器的制作
基于keil5自动配置stm32f103标准库的官网freertos移植
Visual assist plug-in settings for UE4 vs
Construction and use of Changan chain go language smart contract environment
遍历vector容器中的对象的方式
kdevelop新建工程
Introduction to intranet penetration tool FRP
watch监听和computed计算属性的使用和区别
2020-09-23左右值 右值引用 std::move()
股票炒股账号开户安全吗?是靠谱的吗?