4 Could anyone help to solve my question


#1

Hi Guys,

I have some questions about below code.
Can I use the second code to finish what first code done?

SELECT a.dep_month,
       a.dep_day_of_week,
       AVG(a.flight_count) AS average_flights
  FROM (
        SELECT dep_month,
              dep_day_of_week,
               dep_date,
               COUNT(*) AS flight_count
          FROM flights
         GROUP BY 1,2,3
       ) a
 GROUP BY 1,2
 ORDER BY 1,2;

SELECT dep_month,
              dep_day_of_week,
       AVG(count(*)) AS average_flights
    FROM flights
    GROUP BY 1,2;

#2