I need to make the average of the delays of a flight database.
I need to add it to the following query:
SELECT V.Id_Aeropuerto_Destino AS Id_Aeropuerto, C.Nombre AS Ciudad_Destino, A.nombre AS Aeropuerto,
(SELECT SUM((TO_NUMBER(V.Retraso_Salida,'99999999D99','nls_numeric_characters=''.,''')) +
(TO_NUMBER(V.Retraso_Llegada,'99999999D99','nls_numeric_characters=''.,''')))
FROM Vuelo V
WHERE V.Id_Aeropuerto_Destino=Id_Aeropuerto) Retraso_Total
FROM Ciudad C, Aeropuerto A, Vuelo V
WHERE V.Id_Aeropuerto_Destino=A.Id_Aeropuerto AND A.Ciudad = C.Id_Ciudad;
so that the complete query will take out
Id_aeropuerto,
nombre_ciudad,
nombre_aeropuerto,
media_retraso de ese aeropuerto y
total_retraso de ese aeropuerto.
I know it's done with AVG
, but I do not know how.
thanks!