File tree Expand file tree Collapse file tree 1 file changed +0
-22
lines changed Expand file tree Collapse file tree 1 file changed +0
-22
lines changed Original file line number Diff line number Diff line change 1- -- 603. Consecutive Available Seats
2- --
3- -- Several friends at a cinema ticket office would like to reserve consecutive available seats.
4- -- Can you help to query all the consecutive available seats order by the seat_id using the following cinema table?
5- --
6- -- | seat_id | free |
7- -- |---------|------|
8- -- | 1 | 1 |
9- -- | 2 | 0 |
10- -- | 3 | 1 |
11- -- | 4 | 1 |
12- -- | 5 | 1 |
13- -- Your query should return the following result for the sample case above.
14- -- | seat_id |
15- -- |---------|
16- -- | 3 |
17- -- | 4 |
18- -- | 5 |
19- -- Note:
20- -- The seat_id is an auto increment int, and free is bool ('1' means free, and '0' means occupied.).
21- -- Consecutive available seats are more than 2(inclusive) seats consecutively available.
22-
231select c .seat_id from cinema c where c .free = 1
242and
253(
You can’t perform that action at this time.
0 commit comments