Need help with this exercise


#1



Hey, I need a little help with this exercise. I need to find the average total distance flown by day of week and month by using sub queries. But it says that my code is wrong.


select a.dep_month,
			 a.dep_day_of_week,
			 AVG(a.flight_distance) as average_distance 
	 FROM (
        SELECT dep_month,
               dep_day_of_week,
               dep_date,
               COUNT(*) AS flight_distance
          FROM flights
         GROUP BY 1,2,3
       ) a
 GROUP BY 1,2
 ORDER BY 1,2;


#2

COUNT(*) AS flight_distance

here you need to use sum of distance.

SUM(distance) AS flight_distance


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.