title: How to eliminate duplicate rows and group by a column after partitioning over two groups in MySQL?
body: <p>I have a database of flight logs and I would like to summarize the average delay time of for each airline at each distinct airport. Ideally, the query would return each airline and its average departure delay time at a specific airport, grouped by the airport. I've tried the below and it returns the correct values but it sorts the results by airline and returns every line, leading to hundreds of duplicate lines. How can I return just 1 line per airline and group by the airport?</p>
  <pre><code>SELECT 
    ORIGIN_AIRPORT,
    AIRLINE,
    AVG(DEPARTURE_DELAY) OVER (PARTITION BY AIRLINE, ORIGIN_AIRPORT)  AS AVERAGE_DEPARTURE_FLIGHT_DELAY
  FROM FLIGHTS
  WHERE ORIGIN_AIRPORT NOT LIKE('%1%');
  </code></pre>
  <p>Data source: <a href="https://www.kaggle.com/usdot/flight-delays/version/1?select=flights.csv" rel="nofollow noreferrer">https://www.kaggle.com/usdot/flight-delays/version/1?select=flights.csv</a></p>