Why use a subquery for exercise 4: Non-Correlated Subqueries III?


#1

Why do you need to use a subquery? Doesn’t the code below give the same result?

SELECT dep_month,
  dep_day_of_week,
   avg(distance) AS flight_distance
FROM flights
GROUP BY 1,2;

#2

Yes they do give you the same result. I think codecademy is just trying to show you conceptually how it works.


#3

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