Skip to content

Commit a047457

Browse files
committed
feat: add sql solution to lc problems: No.0180
No.0180.Consecutive Numbers
1 parent c72237b commit a047457

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

solution/0100-0199/0180.Consecutive Numbers/README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,27 @@ Result 表:
6060

6161
### **SQL**
6262

63-
```
63+
```sql
6464
select distinct(Num) as ConsecutiveNums from Logs Curr where
6565
Num = (select Num from Logs where id = Curr.id - 1) and
6666
Num = (select Num from Logs where id = Curr.id - 2)
6767
```
6868

69+
```sql
70+
# Write your MySQL query statement below
71+
SELECT DISTINCT l1.num AS ConsecutiveNums
72+
FROM
73+
logs AS l1,
74+
logs AS l2,
75+
logs AS l3
76+
WHERE
77+
l1.id = l2.id - 1
78+
AND
79+
l2.id = l3.id - 1
80+
AND
81+
l1.num = l2.num
82+
AND
83+
l2.num = l3.num
84+
```
85+
6986
<!-- tabs:end -->

solution/0100-0199/0180.Consecutive Numbers/README_EN.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,27 @@ Logs table:
5656

5757
### **SQL**
5858

59-
```
59+
```sql
6060
select distinct(Num) as ConsecutiveNums from Logs Curr where
6161
Num = (select Num from Logs where id = Curr.id - 1) and
6262
Num = (select Num from Logs where id = Curr.id - 2)
6363
```
6464

65+
```sql
66+
# Write your MySQL query statement below
67+
SELECT DISTINCT l1.num AS ConsecutiveNums
68+
FROM
69+
logs AS l1,
70+
logs AS l2,
71+
logs AS l3
72+
WHERE
73+
l1.id = l2.id - 1
74+
AND
75+
l2.id = l3.id - 1
76+
AND
77+
l1.num = l2.num
78+
AND
79+
l2.num = l3.num
80+
```
81+
6582
<!-- tabs:end -->

0 commit comments

Comments
 (0)