Non-Correlated Subqueries III - script error

Please,
Could anyone help me find the error in my script?
Tks!

SELECT a.dep_month,
a.dep_day_of_week,
AVG(a.distance) AS average_distance
FROM( SELECT dep_month,
dep_day_of_week,
dep_date,
SUM(distance) AS flight_distance
FROM flights
GROUP BY 1,2,3
) a
GROUP BY 1,2
ORDER BY 1,2;

Error - Use the select statement to view the table

AVG(a.flight_distance) not AVG(a.distance)

2 Likes

Tks a lot!
It worked well =)