I tried to use the following query in my database:
SELECT MAX(COUNT(DISTINCT c.unique_carrier))
FROM companhia_aerea c, avioes4 a, ponte2 v
WHERE c.unique_carrier = a.UniqueCarrier AND a.TailNumber = v.TailNumb AND V.DepDelay > 0;
This query returns me the following error
mysql error code 1111. invalid use of group function.
Can anyone tell me how I can work around this problem? The structure of the tables is as follows:
CompanhiaAerea (unique_carrier PK, descricao);
Avioes (TailNumber PK, IDModelo FK, IDTipo_licenca FK, unique_carrier FK, IDtipoAviao FK, IDTipo_Motor FK, data_registo, estado, ano);
Voo (IDvoo PK, codigoCancelamento FK, Tail Number FK, iata_origem FK, iata_destino FK, Datavoo, Hora_partida_real, Hora_partida_prevista, Hora_chegada_real, Hora_chegada_prevista, FlightNum, AtualElapsedTime, TempoVoo, distancia, DepDelay, cancelado)