<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>
<Below this line, add a link to the EXACT exercise that you are stuck at.>
<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
<In this course, it often helps to include a screenshot of your whole web browser β that lets everyone see what you see. If you wish to include a screenshot, add it below this line.>
<If you wish to copy/paste in your code, you can use this next section. This will allow others to copy/paste your code for testing β something that they wonβt be able to do with just a screenshot.>
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;
<do not remove the three backticks above>