We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8b37603 commit 340e362Copy full SHA for 340e362
MySQL/consecutive-available-seats-ii.sql
@@ -8,18 +8,18 @@ WITH window_cte AS (
8
FROM Cinema
9
WHERE free = 1
10
), group_cte AS (
11
- SELECT seat_id, (rnk + seat_id) AS group_number
+ SELECT seat_id, (rnk + seat_id) AS group_id
12
FROM window_cte
13
-), order_cte AS (
+), segment_cte AS (
14
SELECT MIN(seat_id) AS first_seat_id,
15
MAX(seat_id) AS last_seat_id,
16
COUNT(*) AS consecutive_seats_len
17
FROM group_cte
18
- GROUP BY group_number
+ GROUP BY group_id
19
ORDER BY NULL
20
)
21
22
SELECT *
23
-FROM order_cte
24
-WHERE consecutive_seats_len = (SELECT MAX(consecutive_seats_len) FROM order_cte)
+FROM segment_cte
+WHERE consecutive_seats_len = (SELECT MAX(consecutive_seats_len) FROM segment_cte)
25
ORDER BY 1;
0 commit comments