Transformations page 4


#1


https://www.codecademy.com/courses/sql-table-transformation/lessons/subqueries/exercises/non-correlated-iii?action=resume


I got the exercise correct but I do not understand the syntax a. on it.



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,
               sum(distance) AS flight_distance
          FROM flights
         GROUP BY 1,2,3
       ) a
 GROUP BY 1,2
 ORDER BY 1,2;


#2

The subquery is a unique table with a temporary name, a. It is this table that the outer query as appied to.


#3

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