File tree Expand file tree Collapse file tree 1 file changed +0
-46
lines changed Expand file tree Collapse file tree 1 file changed +0
-46
lines changed Original file line number Diff line number Diff line change 1
- -- 1285. Find the Start and End Number of Continuous Ranges
2
- --
3
- -- Table: Logs
4
- --
5
- -- +---------------+---------+
6
- -- | Column Name | Type |
7
- -- +---------------+---------+
8
- -- | log_id | int |
9
- -- +---------------+---------+
10
- -- id is the primary key for this table.
11
- -- Each row of this table contains the ID in a log Table.
12
- --
13
- -- Since some IDs have been removed from Logs. Write an SQL query to find the start and end number of continuous ranges in table Logs.
14
- --
15
- -- Order the result table by start_id.
16
- --
17
- -- The query result format is in the following example:
18
- --
19
- -- Logs table:
20
- -- +------------+
21
- -- | log_id |
22
- -- +------------+
23
- -- | 1 |
24
- -- | 2 |
25
- -- | 3 |
26
- -- | 7 |
27
- -- | 8 |
28
- -- | 10 |
29
- -- +------------+
30
- --
31
- -- Result table:
32
- -- +------------+--------------+
33
- -- | start_id | end_id |
34
- -- +------------+--------------+
35
- -- | 1 | 3 |
36
- -- | 7 | 8 |
37
- -- | 10 | 10 |
38
- -- +------------+--------------+
39
- -- The result table should contain all ranges in table Logs.
40
- -- From 1 to 3 is contained in the table.
41
- -- From 4 to 6 is missing in the table
42
- -- From 7 to 8 is contained in the table.
43
- -- Number 9 is missing in the table.
44
- -- Number 10 is contained in the table.
45
- --
46
- -- # Write your MySQL query statement below
47
1
select l1 .log_id as start_id, min (l2 .log_id ) as end_id
48
2
from
49
3
(
You can’t perform that action at this time.
0 commit comments