Table transformation non corelated subqueries


select a.dep_month,
avg(a.flight_distance) as average_distance
select dep_month,
count(distance) as flight_distance
from flights
group by 1,2,3
) a
group by 1,2
order by 1,2


I have to find the average total distance flown by day of week and month .Cn anyone tell me the error in my code?


Hint: It's not count(distance) because you're not counting the number of distance, your calculating the total sum of all the distance :slight_smile:


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