you cannot select a non-aggregated column that is not part of the group by clause. you can turn off the only_full_group_by but i advise not to.
imagine you have a table like this
| ID | flightnumber | timeused |
|----|--------------|----------|
| 1 | A | 10 |
| 2 | B | 20 |
| 3 | B | 30 |
| 4 | C | 40 |
if you group by flightnumber, for the flighnumber B it picks the ID = 3 (because it it MAX() - aggregated column), but it cant decide which to pick for a timeused.
if the only_full_group_by is turned off, the result can be that what you want, but be warned that mysql is free to pick any random value from the grouped rows in this case.
i would do this in two steps, first get the IDs only and then do another select that gets all rows with those IDs