4. Error: near line 1: near "ORDER": syntax error


#1


https://www.codecademy.com/en/courses/sql-table-transformation/lessons/subqueries/exercises/non-correlated-iii

Error: near line 1: near "ORDER": syntax error



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;


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

remove the , after 2


#3

Got it. I feel a lot like I'm copying text and not like I'm learning why
things work.


#4

Yeah.. I understand... Some times i have the same feeling..:frowning2:


#5

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