RienSQL
TASK #232 · Hard · Amadeus

Highest Average Booking Price per Month

Your brief
The bookings table stores ticket bookings: flight flight_id, date booking_date, price price and status status. The airline of a flight is in flights.airline_code.

Write a query that, using confirmed bookings (status = 'Confirmed'), finds for every month of booking_date the airline with the highest average booking price. Return the month mth in the 'YYYY-MM' format, airline_name and avg_price rounded to two decimals. If several airlines share the highest average, return all of them. Sort by mth and then by airline_name.
Expected columnsmth airline_name avg_priceAmadeus
SQL editor
SQLite
Ctrl / ⌘ + ↵
Result

Write a query and run it to see the results.

Schema
airlinesairline_code, airline_name, country
flightsflight_id, flight_number, airline_code, origin, destination, scheduled_departure, actual_departure, status
bookingsbooking_id, flight_id, booking_date, price, status