Skip to content

2793. Status of Flight Tickets 👎

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
SELECT
  Passengers.passenger_id,
  IF(
    RANK() OVER(
      PARTITION BY Passengers.flight_id
      ORDER BY Passengers.booking_time
    ) <= Flights.capacity,
    'Confirmed',
    'Waitlist'
  ) AS status
FROM Passengers
INNER JOIN Flights
  USING (flight_id)
ORDER BY 1;