I am confused as to why ‘dep_date’ is required in this exercise:
I ended up asking for a solution after not being able to run the query. I seemed like the only difference was that the actual solution included dep_date in the subquery, which I didn’t include. I don’t understand why is it needed. Can anyone explain?
This is the code I used before seeing the solution:
SELECT a.dep_month, a.dep_day_of_week, avg(a.flight_distance) as average_distance from ( SELECT dep_month, dep_day_of_week, sum(distance) as flight_distance from flights group by 1,2, ) a group by 1,2;