passenger_with_rank that selects passenger_id, flight_id, and assigns a rank using ROW_NUMBER() partitioned by flight_id and ordered by booking_time.joined_data that joins passenger_with_rank with the Flights table on flight_id and selects passenger_id, rank (rk), and capacity.passenger_id from joined_data and use a CASE statement to check if rk is less than or equal to capacity. If true, return 'Confirmed'; otherwise, return 'Waitlist'.passenger_id in ascending order.erDiagram
Flights {
int flight_id
int capacity
}
Passengers {
int passenger_id
int flight_id
datetime booking_time
}
Flights ||--o{ Passengers : contains